Hi Guys,
Doing some client-side JavaScript development, which requires me to call a client-side API which only accepts one parameter at a time (cough, cough, facebook).
Basically i need to call an API method twice:
someFBApi.requestPerms('email')
someFBApi.requestPerms('publish_stream')
Now, i have a wrapper function for this call which looks like this:
function requestPermission(permission, callback) {
someFBApi.requestPerms(permission, callback);
}
But the problem is, i have to call the function "requestPermission" twice from all over the place:
requestPermission('email', function(perm1granted) {
requestPermission('publish_stream', function(perm2granted) {
// do something with perm 1 and perm 2
I would like to be able to do this:
requestPermissions('email,publish_stream', function(firstPerm,secondPerm) {
// do something with firstPerm, secondPerm
I know i have to call FB API twice (fine), but i want that 'doubling up' to occur in that function (not all over the place). Know what i mean?
So, i'll accept an answer of two forms:
- Can i pass an array of strings, iterate through those? (maybe JSON?)
- Delimeted-string, then split the string in the function.
Keep in mind the function returns a value indicating whether or not the permission was granted. So it needs to accept an array/delimited list of strings and return an array/delimited list of strings.
The more simple the solution, the better. (jQuery fine)