Created
January 12, 2018 09:38
-
-
Save Defite/04863dc4c633a4d073fb2a8dd513c46f to your computer and use it in GitHub Desktop.
Resolve promise when async action has finished
This file contains 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 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