Skip to content

Instantly share code, notes, and snippets.

@creationix
Created March 6, 2011 22:46
Show Gist options
  • Save creationix/857823 to your computer and use it in GitHub Desktop.
Save creationix/857823 to your computer and use it in GitHub Desktop.
bare-bones wrapper to convert PalmBus request API to node style callback API.
// Simple wrapper to make PamlBus requests.
function palmRequest(url, params, callback) {
var req = new PalmServiceBridge();
req.onservicecallback = function (result) {
var data;
try {
data = JSON.parse(result);
} catch (err) {
callback(err);
return;
}
callback(null, data);
};
req.call(url, JSON.stringify(params));
}
palmRequest("palm://com.palm.location/getCurrentPosition", { accuracy: 1, maximumAge: 0, responseTime: 3 }, function (err, data) {
console.log("Final");
if (err) { throw err; }
console.log(JSON.stringify(data));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment