Created
March 11, 2011 01:12
-
-
Save funkatron/865299 to your computer and use it in GitHub Desktop.
This is an example of how you could make a service call to multiple appids, exiting on the first one that succeeds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function callSpaz(serviceParams, onFailure) { | |
var appids = ['com.funkatron.app.spaz-sped', 'com.funkatron.app.spaz', 'com.funkatron.app.spaz-beta'], index = 0; | |
function makeCall() { | |
if (index < appids.length) { | |
Mojo.Log.info('Trying to post with appid %s', appids[index]); | |
var request = new Mojo.Service.Request("palm://com.palm.applicationManager", { | |
method: 'launch', | |
parameters: { | |
id: appids[index], | |
params: serviceParams | |
}, | |
onFailure: function() { | |
Mojo.Log.info('Failed to post with appid %s', appids[index]); | |
index++; // go to next appid | |
makeCall(); // retry | |
}.bind(this) | |
}); | |
} else { | |
Mojo.Log.error('Failed to post to Spaz'); | |
if (onFailure) { | |
onFailure(serviceParams); | |
} | |
} | |
} | |
makeCall(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment