Skip to content

Instantly share code, notes, and snippets.

@mythmon
Created December 23, 2013 19:07
Show Gist options
  • Save mythmon/8102730 to your computer and use it in GitHub Desktop.
Save mythmon/8102730 to your computer and use it in GitHub Desktop.
How I want ES6 promises to work (sometimes).
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