Skip to content

Instantly share code, notes, and snippets.

@Defite
Created January 12, 2018 09:38
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 Defite/04863dc4c633a4d073fb2a8dd513c46f to your computer and use it in GitHub Desktop.
Save Defite/04863dc4c633a4d073fb2a8dd513c46f to your computer and use it in GitHub Desktop.
Resolve promise when async action has finished
var bar = function (data) {
return setTimeout(function() {
return 'async data';
}, 1000);
}
var foo = function () {
this._promise new Promise(function(resolve, reject) {
this.once('bar', resolve)
})
}
var submitFunc = function() {
foo.then(function() {
//do some submit stuff
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment