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

flux-dispatcher

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flux-dispatcher

A Flux dispatcher ready for action.

  • 1.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

flux-dispatcher

A Flux dispatcher ready for action.

Build Status Dependency Status devDependency Status

Install

$ npm install flux-dispatcher

Note: Your project should have it's own flux dependency installed. We depend on flux via peerDependencies.

Usage

var myDispatcher = require('flux-dispatcher'); // that's us, such meta
var Constants = require('./Constants');
var ApiUtil = require('./ApiUtil');

var VIEW_ACTION = Constants.PayloadSources.VIEW_ACTION;
var SERVER_ACTION = Constants.PayloadSources.SERVER_ACTION;
var ActionTypes = Constants.ActionTypes;
var dispatch = myDispatcher.handleAction;

var Actions = {
    sendRequest: function (data) {

        dispatch(VIEW_ACTION, ActionTypes.SEND_REQUEST, data);

        var request = {
            method: 'POST',
            url: '/api/endpoint',
            data: data
        };

        ApiUtil(request, function (err, response) {

            dispatch(SERVER_ACTION, ActionTypes.RECEIVE_RESPONSE, response);
        });
    }
};

module.exports = Actions;

API

handleAction(source, type, data)

This builds a payload and dispatches it. The payload will look like this:

{
    source: source,
    action: {
      type: type,
      data: data
    }
}
handleAction(type, data)

If you don't pass a source argument, the payload will look like this:

{
    action: {
      type: type,
      data: data
    }
}

License

MIT

Don't forget

What you create with flux-dispatcher is more important than flux-dispatcher.

Keywords

FAQs

Package last updated on 08 Sep 2016

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