Skip to content

Instantly share code, notes, and snippets.

@rexxars
Created April 4, 2014 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rexxars/9972866 to your computer and use it in GitHub Desktop.
Save rexxars/9972866 to your computer and use it in GitHub Desktop.
// In some app (say, a flickr-image-app):
appApi.emit('image-selected-for-upload', { url: someUrl, source: 'flickr' })
appApi.on('image-uploaded', function(e) {
if (e.data.source !== 'flickr') {
return;
}
alert('Image uploaded');
});
// In some other app (Imbo, for instance):
appApi.on('image-selected-for-upload', function(e) {
imbo.addImageFromUrl(e.data.url, function(err, response) {
if (err) {
return console.error(err);
}
appApi.emit('image-uploaded', { source: e.source });
});
});
// Which also would allow multiple apps to both emit and listen for events in an intuitive manner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment