Skip to content

Instantly share code, notes, and snippets.

@willhoney7
Last active December 17, 2018 23:42
Show Gist options
  • Save willhoney7/ea22248b4c97bce68ad93b436f0cb90b to your computer and use it in GitHub Desktop.
Save willhoney7/ea22248b4c97bce68ad93b436f0cb90b to your computer and use it in GitHub Desktop.
A simple way to do a deferred or inside-out promise.
interface IDeferredPromise<T> {
resolve: (T) => void,
reject: (T) => void,
promise: Promise<T>,
}
function DeferredPromise<T>(): IDeferredPromise<T> {
this.promise = new Promise<T>((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment