Socket
Socket
Sign inDemoInstall

announcement

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    announcement

Asynchronous event emitter and aggregator.


Version published
Weekly downloads
3
Maintainers
1
Install size
14.4 kB
Created
Weekly downloads
 

Readme

Source

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.

FAQs

Last updated on 27 Jan 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc