Skip to content

Instantly share code, notes, and snippets.

@tai2
Created June 12, 2019 02:30
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 tai2/4d0df325ec8d2938fe0918317993256d to your computer and use it in GitHub Desktop.
Save tai2/4d0df325ec8d2938fe0918317993256d to your computer and use it in GitHub Desktop.
export default class Deferred<T> {
promise: Promise<T>
resolve: (value?: T | PromiseLike<T>) => void
reject: (reason?: any) => void
constructor() {
this.resolve = () => {}
this.reject = () => {}
this.promise = new Promise<T>((resolve, reject) => {
this.reject = reject;
this.resolve = resolve;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment