@wbe/deferred-promise
v2.4.0
Published
Create a deferred promise who can be resolved or rejected from anywhere.
Downloads
64
Readme
@wbe/deferred-promise
Create a deferred promise who can be resolved or rejected from anywhere.
Installation
$ npm install -s @wbe/deferred-promise
How to use
import { deferredPromise } from "@wbe/deferred-promise";
// create deferred promise
const deferred = deferredPromise();
deferred.promise.then(() => {
// deferredPromise is resolved!
});
// when needed, resolve this promise
deferred.resolve();
// or reject it
deferred.reject();