Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 11 days ago
JSON representation

Simple TypeScript/ES2015 class to allow to create a promise and to be resolved/rejected later

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() );
```