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

dispatchr

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dispatchr

A Flux dispatcher for applications that run on the server and the client.

  • 0.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Dispatchr Build Status

A Flux dispatcher for applications that run on the server and the client.

Usage

For a more detailed example, see our example application.

Let's start with a store that can handle the actions:

var util = require('util'),
    EventEmitter = require('events').EventEmitter;

function ExampleStore(context) {
    this.navigating = false;
}

util.inherits(ExampleStore, EventEmitter);

ExampleStore.handlers = {
    'NAVIGATE': 'handleNavigate'
};

ExampleStore.prototype.handleNavigate = function () {
    this.navigating = true;
    this.emit('update'); // Store may be listening for updates to state
    this.emit('final'); // Action has been fully handled
};

ExampleStore.prototype.getState = function () {
    return {
        navigating: this.navigating
    };
};

Now let's initialize our dispatcher and dispatch an action:

var Dispatchr = require('dispatchr'),
    ExampleStore = require('./example-store.js'),
    context = {};

Dispatchr.registerStore(ExampleStore);

var dispatcher = new Dispatchr(context);

dispatcher.dispatch('NAVIGATE', {}, function () {
    // Action has been handled fully
});

License

This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.

FAQs

Package last updated on 04 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