Created
December 23, 2013 19:07
-
-
Save mythmon/8102730 to your computer and use it in GitHub Desktop.
How I want ES6 promises to work (sometimes).
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
var p; | |
var stream; | |
function foo() { | |
p = new Promise(); | |
stream = TweakWidgets(); | |
stream.once('message', bar); | |
return p; | |
} | |
function bar(data) { | |
p.resolve(data); | |
} | |
foo().then(function() { /* Called after the widget has been tweaked. */ }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment