simple-event-dispatch
A simple event dispatcher for loosely coupling code
Install
npm install simple-event-dispatch --save
Example usage in an Express application
comment-controller.js
var dispatch = ; /** * Create the comment dispatch module */var commentDispatch = dispatch; /** * Create a comment. The first parameter is always a deferred object */commentDispatch;
Somewhere in app.js
/** * Register the comment dispatcher. The comment dispatcher is now available * anywhere through simple-event-dispatch */;
comment-routes.js
var dispatch = ; router; moduleexports = router;
Or:
/** * Retrieve the comment dispatcher instance */var commentDispatch = dispatch; router;