Skip to content

Instantly share code, notes, and snippets.

@aeinbu
Created November 6, 2020 13:11
Show Gist options
  • Save aeinbu/59bf1e946e6de3d299e3d0bdd6cb3f30 to your computer and use it in GitHub Desktop.
Save aeinbu/59bf1e946e6de3d299e3d0bdd6cb3f30 to your computer and use it in GitHub Desktop.
function Deferred() {
this.resolve = null;
this.reject = null;
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
}
var d = new Deferred();
d.promise.then(x => {
console.log("ok");
}).catch(x => {
console.log("failed");
});
console.log("start");
d.resolve();
//d.reject();
console.log("end");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment