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

dispatchr

Package Overview
Dependencies
Maintainers
2
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.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by4.01%
Maintainers
2
Weekly downloads
 
Created
Source

Dispatchr Build Status Dependency 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.

Keywords

FAQs

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