Skip to content

nitzantomer/future.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A different way to use promises

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published