fibrous-loggable-futures
v1.0.0
Published
Fibrous mixin to log results of futures, and wait for logged results
Downloads
4
Readme
Fibrous Loggable Futures
Fibrous mixin to log results of futures, and wait for logged results
Usage
npm install fibrous-loggable-futures
var fibrous = require('fibrous'),
loggableFutures = require('fibrous-loggable-futures'),
logger = {
info: function(message),
error: function(context, message)
}
loggableFutures(fibrous, logger)
Now you can log results of futured work:
email.future.send(...).andLogResults("you'll get this in the future")
Pass a flag if you only want to hear about errors:
email.future.send(...).andLogResults("and this one too", {errorsOnly: true})
For quick and dirty synchronization, you can wait for all logged futures to resolve:
sendAll = ->
email.future.send(...).andLogResults('message')
email.future.send(...).andLogResults('message')
/* Somewhere else, like a test */
fibrous.captureLoggedFutures()
sendAll()
fibrous.sync.waitForLoggedFutures()
// ...
fibrous.uncaptureLoggedFutures()
Contributing
Please follow our Code of Conduct when contributing to this project.
$ git clone https://github.com/goodeggs/fibrous-loggable-futures && cd fibrous-loggable-futures
$ npm install
$ npm test
Module scaffold generated by generator-goodeggs-npm.