promise-effect

1.0.0 • Public • Published

promise-effect Build Status

Runs a function as promise callback and resolves the original value

Install

$ npm install --save promise-effect

Usage

const effect = require('promise-effect');

Promise
	.resolve(1)
	.then(effect(x => {
		// Destroy the world
		// setSomeCache('My x value' , x);
		console.log(x) //=> 1;
	}))
	.then(x => {
		x === 1 //=> true
	});

WHY

Because modularity FTW and i was seeing this pattern a lot. Much cleaner now :)

API

effect(fn)

fn

Type: function

single param function that gets previous resolved value as parameter

License

MIT © Nikhil Srivastava

Readme

Keywords

Package Sidebar

Install

npm i promise-effect

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • niksrc