announcement

0.1.0 • Public • Published

announcement NPM version

Asynchronous event emitter and aggregator.

Install

Install with npm

npm i announcement --save

Run tests

npm test

Usage

var Announcement = require('announcement');

API

Announcement

Main entry point of Announcement event emitter/aggregator

var Announcement = require('announcement');
var announcement = new Announcment();

.on

Register a listener for an event.

  • event {String|Function}: Event type to listen for.
  • cb {Function}: Callback invoked when event type is emitted.
  • returns {Function}: Original callback function or handler function to use to remove listener.
announcement.on('foo', function (data) {
  // do something with data
});
 
var FooEvent = function () {};
announcement.on(FooEvent, function (data) {
  // data will be an instance of FooEvent
  // do something with data
});

.emit

Asynchronously emit an event and additional data.

  • event {String|Object}: Event type to emit.
// emit string event
announcement.emit('foo', { bar: 'baz' });
 
// emit typed event
var foo = new FooEvent();
foo.bar = 'baz';
announcement.emit(foo);

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Brian Woodward

License

Copyright (c) 2015 Brian Woodward
Released under the MIT license


This file was generated by verb on January 27, 2015.

Readme

Keywords

none

Package Sidebar

Install

npm i announcement

Weekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • doowb