1.0.0 • Published 8 years ago

future.js v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

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