How to use flux - 10 common examples

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 mistadikay / flux-http-example / src / flux / stores / search-store.js View on Github external
switch (action.actionType) {

            case actionsConstants.SEARCH_START:
                SearchStore.emit(actionsConstants.SEARCH_START);
                break;

            case actionsConstants.SEARCH_RESULTS:
                searchResults = action.results;
                searchError = null;
                SearchStore.emit(actionsConstants.SEARCH_RESULTS);
                break;

            case actionsConstants.SEARCH_ERROR:
                searchResults = null;
                searchError = action.error;
                SearchStore.emit(actionsConstants.SEARCH_ERROR);
                break;
            default:
            // no op
        }
    }
);
github mistadikay / flux-http-example / src / flux / stores / search-store.js View on Github external
function(action) {
        switch (action.actionType) {

            case actionsConstants.SEARCH_START:
                SearchStore.emit(actionsConstants.SEARCH_START);
                break;

            case actionsConstants.SEARCH_RESULTS:
                searchResults = action.results;
                searchError = null;
                SearchStore.emit(actionsConstants.SEARCH_RESULTS);
                break;

            case actionsConstants.SEARCH_ERROR:
                searchResults = null;
                searchError = action.error;
                SearchStore.emit(actionsConstants.SEARCH_ERROR);
                break;
            default:
            // no op
        }
    }
);
github mistadikay / flux-http-example / src / flux / stores / search-store.js View on Github external
function(action) {
        switch (action.actionType) {

            case actionsConstants.SEARCH_START:
                SearchStore.emit(actionsConstants.SEARCH_START);
                break;

            case actionsConstants.SEARCH_RESULTS:
                searchResults = action.results;
                searchError = null;
                SearchStore.emit(actionsConstants.SEARCH_RESULTS);
                break;

            case actionsConstants.SEARCH_ERROR:
                searchResults = null;
                searchError = action.error;
                SearchStore.emit(actionsConstants.SEARCH_ERROR);
                break;
            default:
            // no op
        }
    }
);
github mistadikay / flux-http-example / src / flux / stores / search-store.js View on Github external
function(action) {
        switch (action.actionType) {

            case actionsConstants.SEARCH_START:
                SearchStore.emit(actionsConstants.SEARCH_START);
                break;

            case actionsConstants.SEARCH_RESULTS:
                searchResults = action.results;
                searchError = null;
                SearchStore.emit(actionsConstants.SEARCH_RESULTS);
                break;

            case actionsConstants.SEARCH_ERROR:
                searchResults = null;
                searchError = action.error;
                SearchStore.emit(actionsConstants.SEARCH_ERROR);
                break;
            default:
            // no op
        }
    }
);
github mistadikay / flux-http-example / src / flux / stores / search-store.js View on Github external
function(action) {
        switch (action.actionType) {

            case actionsConstants.SEARCH_START:
                SearchStore.emit(actionsConstants.SEARCH_START);
                break;

            case actionsConstants.SEARCH_RESULTS:
                searchResults = action.results;
                searchError = null;
                SearchStore.emit(actionsConstants.SEARCH_RESULTS);
                break;

            case actionsConstants.SEARCH_ERROR:
                searchResults = null;
                searchError = action.error;
                SearchStore.emit(actionsConstants.SEARCH_ERROR);
                break;
            default:
            // no op
github mistadikay / flux-http-example / src / flux / stores / search-store.js View on Github external
function(action) {
        switch (action.actionType) {

            case actionsConstants.SEARCH_START:
                SearchStore.emit(actionsConstants.SEARCH_START);
                break;

            case actionsConstants.SEARCH_RESULTS:
                searchResults = action.results;
                searchError = null;
                SearchStore.emit(actionsConstants.SEARCH_RESULTS);
                break;

            case actionsConstants.SEARCH_ERROR:
                searchResults = null;
                searchError = action.error;
                SearchStore.emit(actionsConstants.SEARCH_ERROR);
                break;
            default:
            // no op
        }
github wevote / WebApp / src / js / dispatcher / Dispatcher.js View on Github external
import Dispatcher from 'flux/lib/Dispatcher';
import $ajax from '../utils/service';
import { httpLog } from '../utils/logging';


Dispatcher.prototype.$ajax = $ajax;

Dispatcher.prototype.loadEndpoint = function (endpoint, data = {}) {
  if (this.$ajax instanceof Function !== true) throw new Error("$ajax handler not initialized");

  // console.log("Ajax request in Dispatcher: " + endpoint);
  return this.$ajax({
    endpoint,
    data,
    success: (res) => {
      httpLog(`AJAX Response to endpoint: ${endpoint}`);
      this.dispatch({ type: endpoint, res });
    },

    error: (err) => {
      httpLog(`AJAX ERROR Response to endpoint: ${endpoint}`);
      this.dispatch({ type: `error-${endpoint}`, err });
    },
  });
github wevote / WebApp / src / js / dispatcher / Dispatcher.js View on Github external
import Dispatcher from 'flux/lib/Dispatcher';
import $ajax from '../utils/service';
import { httpLog } from '../utils/logging';


Dispatcher.prototype.$ajax = $ajax;

Dispatcher.prototype.loadEndpoint = function (endpoint, data = {}) {
  if (this.$ajax instanceof Function !== true) throw new Error("$ajax handler not initialized");

  // console.log("Ajax request in Dispatcher: " + endpoint);
  return this.$ajax({
    endpoint,
    data,
    success: (res) => {
      httpLog(`AJAX Response to endpoint: ${endpoint}`);
      this.dispatch({ type: endpoint, res });
    },

    error: (err) => {
      httpLog(`AJAX ERROR Response to endpoint: ${endpoint}`);
      this.dispatch({ type: `error-${endpoint}`, err });
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));
    });
  }