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

https://github.com/nitzantomer/future.js

A different way to use promises
https://github.com/nitzantomer/future.js

Last synced: about 1 month ago
JSON representation

A different way to use promises

Awesome Lists containing this project

README

          

# future.js

A simple wrapper for the promise object which can be used when the logic of the async operation should not be implemented
inside the promise.

A simple example:

```typescript
class MyRemoteDataFetcher {
fetch(): Promise {
let future = new Future();

// make a remote request, when it returns:
future.resolve(VALUE_FROM_REMOTE);
// or if it fails:
future.reject(MESSAGE);

return future.asPromise();
}
}
```