1.1.0 • Published 9 years ago

frp-promise v1.1.0

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

frp-promise

experimental

will convert a Promise to a frp event. If the promise reject's a Javascript Error will be returned with the rejecting message.

Usage

NPM

Example:

var promise = require( 'bluebird' );
var frpPromise = require( 'frp-promise' );

var resolving = promise.resolve( 'I am good' );
var rejecting = promise.reject( 'I am bad' );

frpPromise( resolving )
.watch( onWatch );

frpPromise( rejecting )
.watch( onWatch );

function onWatch( value ) {
	
	if( value instanceof Error ) {

		throw value; // will throw an Error with the message value of 'I am bad'
	} else {

		console.log( value ); // will console.log 'I am good'
	}
}

License

MIT, see LICENSE.md for details.