@nitzan/future.js

1.0.1 • Public • Published

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:

class MyRemoteDataFetcher {
	fetch(): Promise<string> {
		let future = new Future<string>();
		
		// make a remote request, when it returns:
		future.resolve(VALUE_FROM_REMOTE);
		// or if it fails:
		future.reject(MESSAGE);
		
		return future.asPromise();
	}
}

Readme

Keywords

Package Sidebar

Install

npm i @nitzan/future.js

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • nitzan