remote-switch
Promise wrapper for remote resolve/reject.
Description
Making 'chain of Promise' but not want to execute immediately,
Requirement
No deps, but Promise required.
Usage
var RemoteSwitch = require('@berlysia/remote-switch');
var rs = new RemoteSwitch;
var log = console.log.bind(console);
rs
.then(function(){return 123})
.then(log)
.then(function(){return 456})
.then(log);
rs.fire();
rs
.then(function(){return 123})
.then(log)
.then(function(){return 456})
.then(log);
rs.then(func)
is syntax sugar of promise = promise.then(func)
.
if you want to access last promise, rs.current
is what you want.
rs
.then(function(){return 123})
.then(console.log.bind(console))
.then(spy)
.then(assert(!spy.called))
.then(()=>assert(spy.called))
.fire();
Install
npm install @berlysia/remote-switch
Licence
MIT
Author
berlysia