behave-events
An extended EventEmitter class with advanced event support (transactions, commands, and requests)
behave-events
is an event module that extends Node's EventEmitter
class. It adds some common event patterns to the class, making it a fully featured event solution.
EventEmitter
If you are unfamiliar with Node's EventEmitter class, I would suggest reading the documentation!
request / response / stopResponding
Easily set up reqres in your application with response
, request
, and stopResponding
. Great for getting access to otherwise inaccessible state.
let collection = a: 1 a: 2 a: 3; { thisevents = ; thisevents; } // ... { thisevents; } // ... var myClass = ;thisevents; // => [{a: 1}, {a: 2}, {a: 3}] // ... myClass;thisevents; // => undefined
command / execute / stopExecuting
Pass off tasks off to other modules with command
, execute
, and stopExecuting
. Great for things like queues and processing.
;; var router = ; router; // ...
transaction / transact / stopTransacting
Sometimes you need to pass off work to another module, but you need confirmation that the task was completed. Some people use request
for this, but I feel that violates the contract of reqres
, with transaction
, transact
, and stopTransacting
you can have a declarative way of registering transactions between your modules.
;; billing; // ...
Release History:
- 0.1.0 Initial Release
- 0.1.1 Cleaned up examples in readme
- 0.1.2 Converted tests to ES6
- 0.1.3 Added build badge