Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

barracks

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

barracks

An event dispatcher for the flux architecture

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Barracks

Build Status Coverage Status

An event dispatcher for the flux architecture. Best used with browserify.

Installation

npm i --save barracks

Overview

/**
 * Initialize barracks.
 */

var Dispatcher = require('barracks');
var dispatcher = Dispatcher();

/**
 * Register a new callback.
 */

dispatcher.register('eventName', function(arg) {
  return arg + ' got triggered';
});

/**
 * Dispatch registered callbacks for 'eventName'.
 */

dispatcher.dispatch('eventName', 'Loki');
// => 'Loki got triggered'

API

.register()

Register a new object to the store. Takes a {String} action that determines the message it should respond to, and a {Function} callback that executes the response.

dispatcher.register('eventName', function(arg) {
  return arg;
});

dispatcher.register('otherEvent', function() {
  return 'hi';
)});
.dispatch()

Trigger all callbacks corresponding to {String} action and provide them an argument of {Mixed} data.

dispatcher.dispatch('eventName', 12);
// => 12

dispatcher.dispatch('otherEvent');
// => throw Error

dispatcher.dispatch('otherEvent', null);
// => 'hi'

License

MIT © Yoshua Wuyts

Keywords

FAQs

Package last updated on 07 Jun 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc