eventuate-next
Act upon the next produced value of an eventuate
example
var eventuate = next = var service = login: // with a callback // or with a promise servicelogin // will be logged (twice)servicelogin // will not be logged
api
var next =
next(eventuate [, cb])
next
requires a (non-basic) eventuate
as it's 1st argument, and optionally
accepts an error-first callback, cb
, as a 2nd argument. The next
function
returns a Promise
. When the given eventuate
produces it's next value, the
Promise
will resolve with the value. If a callback was provides, it will be
executed with a falsy error and the value.
If, while next
is waiting on a value to be produces, the consumer that next
attaches to the eventuate
is removed, or the eventuate
is destroyed, then
the Promise
will be rejected with a NextCancelledError
(see below). If a
callback was provided, it will be executed with the NextCancelledError
. The
error object will have a property of destroyed
which will be a boolean, and
can be used to determine if the eventuate
was destroyed, or if an action
removed the next
consumer while leaving the eventuate
in-tact.
errors
var errors =
errors.NextCancelledError
Constructor of error supplied to callback or Promise rejection in the event the
next
consumer is removed or the eventuate
is destroyed before the
eventuate
produces a value.
install
With npm do:
npm install --save eventuate-next
testing
npm test
Or to run tests in phantom: npm run phantom
coverage
npm run view-cover
This will output a textual coverage report.
npm run open-cover
This will open an HTML coverage report in the default browser.