Package Exports
- eprom
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eprom) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
eprom
eprom is an enhanced promise implementation. It works by wrapping a globally available Promise class and is as compliant with the Promises/A+ spec as the global Promise is.
In addition to the usual then, call and finally instance methods, it provides resolve and reject methods. In this regard, it resembles jQuery's Deferred object. On top of that, it features a reset method that enables repeat fulfillment.
Installation
Using NPM:
npm install -S epromUsing Yarn:
yarn add epromAPI
eprom's EnhancedPromise mimics more usual Promises in every way. As such, it provides all class (resolve, reject, all, race) and instance (then, catch, finally) methods these provide.
enhancedPromise.resolve(value)
This method resolves an EnhancedPromise's inner Promise, triggering the execution of all onFulfilled handlers.
const enhancedPromise = new EnhancedPromise();
enhancedPromise.then(value => console.log(value));
enhancedPromise.resolve('foo');
// logs 'foo'enhancedPromise.reject(reason)
This method rejects an EnhancedPromise's inner Promise, triggering the execution of all onRejected handlers.
const enhancedPromise = new EnhancedPromise();
enhancedPromise.catch(reason => console.err(reason));
enhancedPromise.reject('bar');
// logs 'bar'enhancedPromise.reset()
This method creates a fresh inner Promise and thus allows for the re-fulfillment of an EnhancedPromise. A typical use case for this is handling repeat builds triggered by Webpack in watch mode.
const enhancedPromise = new EnhancedPromise();
enhancedPromise.then(value => console.log(value));
enhancedPromise.resolve('foo');
// logs 'foo'
enhancedPromise.reset();
enhancedPromise.then(value => console.log(value));
enhancedPromise.resolve('bar');
// logs 'bar'