Created
April 4, 2014 11:45
-
-
Save rexxars/9972866 to your computer and use it in GitHub Desktop.
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
// 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