https://github.com/pedromsilvapt/data-future
Simple TypeScript/ES2015 class to allow to create a promise and to be resolved/rejected later
https://github.com/pedromsilvapt/data-future
Last synced: 4 months ago
JSON representation
Simple TypeScript/ES2015 class to allow to create a promise and to be resolved/rejected later
- Host: GitHub
- URL: https://github.com/pedromsilvapt/data-future
- Owner: pedromsilvapt
- Created: 2018-04-19T14:10:03.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-25T20:39:58.000Z (about 6 years ago)
- Last Synced: 2025-02-14T20:13:24.786Z (5 months ago)
- Language: TypeScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Future
> Simple TypeScript/ES2015 class to allow to create a promise and to be resolved/rejected later
# Installation
```shell
npm install --save data-future
```# Usage
```typescript
import { Future } from 'data-future';const future = new Future();
futrue.promise.then( number => console.log( number ) ); // 1
// Can be called anytime after instantiating a Future object
future.resolve( 1 );
``````typescript
import { Future } from 'data-future';const future = new Future();
futrue.promise.catch( err => console.error( err ) ); // Error {}
// Can be called anytime after instantiating a Future object
future.reject( new Error() );
```