How to use the flux.Dispatcher function in flux

To help you get started, we’ve selected a few flux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github erfangc / GigaGrid / src / components / GigaGrid.tsx View on Github external
constructor(props: GigaProps) {
        super(props);
        this.dispatcher = new Dispatcher();
        this.store = GigaGrid.createStore(props, this.dispatcher);
        this.state = this.store.getState();
        // do not call setState again, this is the only place! otherwise you are violating the principles of Flux
        // not that would be wrong but it would break the 1 way data flow and make keeping track of mutation difficult
        this.store.addListener(() => {
            this.setState(this.store.getState());
        });
    }
github steida / songary / src / client / lib / flux.js View on Github external
_createDispatcher() {
    // No need to dispose dispatcher, GC will eat it.
    this._dispatcher = new Dispatcher;
    Map(this.actionsAndStores).forEach((array, feature) => {
      const {store} = Flux.findActionsAndStores(array);
      if (!store) return;
      this._dispatcher.register(this._onDispatch.bind(this, feature, store));
    });
  }
github sasha-alias / sqltabs / src / Dispatcher.js View on Github external
GNU General Public License for more details.

      You should have received a copy of the GNU General Public License
      along with this program.  If not, see .
*/

var Dispatcher = require('flux').Dispatcher;
var TabsStore = require('./TabsStore');
var Executor = require('./Executor');
var Config = require('./Config');
var History = require('./History');
var Cloud = require('./Cloud');

var AppDispatcher = new Dispatcher();
var SignalsDispatcher = new Dispatcher();
var DBDispatcher = new Dispatcher();

SignalsDispatcher.register(function(payload){
// separate dispatcher needed to avoid parallel actions execution
    switch(payload.eventName){
        case 'execute-script':
            TabsStore.setRenderer('plain');
            TabsStore.trigger('execute-script-'+TabsStore.selectedTab);
            break;
        case 'execute-block':
            TabsStore.setRenderer('auto');
            TabsStore.trigger('execute-block-'+TabsStore.selectedTab);
            break;
        case 'execute-all':
            TabsStore.setRenderer('auto');
            TabsStore.trigger('execute-all-'+TabsStore.selectedTab);
            break;
github kresusapp / kresus / client / store.js View on Github external
import { assert, debug, maybeHas, has, translate as $t, NONE_CATEGORY_ID,
        setupTranslator, localeComparator } from './helpers';

import { Account, Alert, Bank, Category, Operation, OperationType } from './models';

import { Dispatcher } from 'flux';

import * as backend from './backend';

import { genericErrorHandler } from './errors';

import DefaultSettings from '../shared/default-settings';

const events = new EE;
const flux = new Dispatcher;

// Private data
const data = {
    categories: [],
    // maps category ids to categories
    categoryMap: new Map(),

    currentBankId: null,
    currentAccountId: null,

    settings: new Map(DefaultSettings),

    // Map of Banks (id -> bank)
    // (Each bank has an "account" field which is a map (id -> account),
    //  each account has an "operation" field which is an array of Operation).
    banks: new Map,
github microsoft / TypeScriptSamples / react-with-type-safe-flux / src / dispatcher / AppDispatcher.ts View on Github external
import { Dispatcher } from 'flux';

export class TypedEvent<p> {
  constructor(public payload: P) {}
}

export type Event = TypedEvent;

const dispatcherInstance: Flux.Dispatcher = new Dispatcher();

export const AppDispatcher = dispatcherInstance;
</p>
github kenwheeler / mcfly / lib / Dispatcher.js View on Github external
'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _flux = require('flux');

/** Creates a singlar instance of Facebook's Dispatcher */
var appDispatcher = new _flux.Dispatcher();

exports.default = appDispatcher;
github goatslacker / microflux / src / flux.js View on Github external
function MicroFlux() {
  this.dispatcher = new Dispatcher()
}
github danesparza / Dashboard / src / dispatcher / AppDispatcher.js View on Github external
/*
 * AppDispatcher
 *
 * A singleton that operates as the central hub for application updates.
 */
var Dispatcher = require('flux').Dispatcher;

module.exports = new Dispatcher();
github everplans / fluxxed_up / src / lib / fu-dispatcher.js View on Github external
import { Dispatcher } from 'flux'
import assign from 'object-assign'
import invariant from 'invariant'

var AppDispatcher = assign(new Dispatcher(), {
  dispatch(action) {
    invariant(action.actionType, 'action type is undefined.')
    Dispatcher.prototype.dispatch.call(this, action)
  }
})

module.exports = AppDispatcher
github benoitvallon / react-native-nw-react-calculator / common / constants / dispatcher / AppDispatcher.js View on Github external
'use strict';

var Dispatcher = require('flux').Dispatcher;

module.exports = new Dispatcher();