@pedromsilva/data-future
v1.1.3
Published
Simple TypeScript/ES2015 class to allow to create a promise and to be resolved/rejected later
Downloads
4,578
Maintainers
Readme
Future
Simple TypeScript/ES2015 class to allow to create a promise and to be resolved/rejected later
Installation
npm install --save data-future
Usage
import { Future } from 'data-future';
const future = new Future<number>();
futrue.promise.then( number => console.log( number ) ); // 1
// Can be called anytime after instantiating a Future object
future.resolve( 1 );
import { Future } from 'data-future';
const future = new Future<number>();
futrue.promise.catch( err => console.error( err ) ); // Error {}
// Can be called anytime after instantiating a Future object
future.reject( new Error() );