fibrous-loggable-futures

1.0.0 • Public • Published

Fibrous Loggable Futures

Fibrous mixin to log results of futures, and wait for logged results

NPM version Build Status MIT License

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.

Readme

Keywords

Package Sidebar

Install

npm i fibrous-loggable-futures

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • hurrymaplelad