Socket
Book a DemoInstallSign in
Socket

flux-queue-dispatcher

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

flux-queue-dispatcher

Implements the Flux dispatcher with queued actions.

0.1.3
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Flux dispatcher with queued actions

Build status

Implements the Flux dispatcher with queued actions.

Motivation

The basic implementation prevents us from running dispatch() while dispatching. However, if dispatch() is triggered by, for example, an AJAX request, we can't guarantee it is not called during a dispatch.

To handle this situation all dispatch() calls are put into a queue and executed sequentially.

Usage

Set up the dispatcher module.

// @file /dispatcher.js
import QueueDispatcher from 'flux-queue-dispatcher';

var dispatcher = new QueueDispatcher();
export default dispatcher;
export const dispatch = dispatcher.queueDispatch.bind(dispatcher);

Use it whenever actions are triggered.

// @file /comp1.js
import React from 'react';
import {dispatch} from './dispatcher.js';

class Comp1 extends React.Component {
    _event() {
        // Make asynchornous dispatch
        setTimeout(function() {
            dispatch({
                type: 'action1'
            });
        }, 100);
        // The time of the callback execution is unknown
        $.get('/data', function(result) {
            dispatch({
                type: 'action2',
                payload: result
            });
        });
    }
    render() {
        return <a click={this._event}>Click me!</a>;
    }
}
export default Comp1;

Read more about the Flux dispatcher.

Keywords

flux

FAQs

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.