Skip to content

Instantly share code, notes, and snippets.

@AlexGilleran
Created August 21, 2017 01:20
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 AlexGilleran/74756fab69d9f56294e99f0706982f2a to your computer and use it in GitHub Desktop.
Save AlexGilleran/74756fab69d9f56294e99f0706982f2a to your computer and use it in GitHub Desktop.
Typescript Deferred
export default class Deferred<T> {
promise: Promise<T>;
resolve: (value?: T | PromiseLike<T>) => void;
reject: (reason?: any) => void;
constructor() {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment