controllable-promise
v1.3.0
Published
Control when a JavaScript promise resolves or rejects.
Downloads
3
Readme
Controllable Promise
Control when a JavaScript promise resolves or rejects.
Getting started
npm i controllable-promise
Create the promise and manually invoke the resolve
function:
import ControllablePromise from 'controllable-promise';
const setupPromise = new ControllablePromise()
setupPromise.then(() => {
executeSomeAfterSetupLogic();
})
callSomeSetupLogic();
setupPromise.resolve();
Or use the promise as you would normally:
import ControllablePromise from 'controllable-promise';
const setupPromise = new ControllablePromise(resolve => {
callSomeSetupLogic();
// Below is optional, you can still manually invoke the `resolve`
// later using `setupPromise.resolve()`
resolve();
})
await setupPromise;
executeSomeAfterSetupLogic();