How to use the fluxxor.createStore function in fluxxor

To help you get started, we’ve selected a few fluxxor 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 onefinestay / django-mediacat / static / js / stores / crops.js View on Github external
m = matrix.multiply(translateMatrix, m);
  return valuesFromMatrix(m);
};

var getCropOverflow = function(media, anchorX, anchorY, values) {
  // Sometimes we scale too far, so work out the scale necessary to fix it.
  var x1 = values.x1 < 0 ? -values.x1 / (anchorX - values.x1) : 0;
  var y1 = values.y1 < 0 ? -values.y1 / (anchorY - values.y1): 0;
  var x2 = values.x2 > media.get('width') ? (values.x2 - media.get('width')) / (values.x2 - anchorX) : 0;
  var y2 = values.y2 > media.get('height') ? (values.y2 - media.get('height')) / (values.y2 - anchorY) : 0;

  return {x1, y1, x2, y2, reverseScale: 1 - Math.max(x1, y1, x2, y2)};
};


var CropStore = Fluxxor.createStore({
  initialize: function(options) {
    this.bindActions(
      constants.CATEGORY_SELECTED, this.onCategorySelect,
      constants.MEDIA_SELECTED, this.onMediaSelect,
      constants.CROP_GET_START, this.onCropGetStart,
      constants.CROP_GET_SUCCESS, this.onCropGetSuccess,
      constants.CROP_SELECTED, this.onCropSelect,
      constants.CROP_DESELECTED, this.onCropDeselect,
      constants.CROP_MOVE, this.onCropMove,
      constants.CROP_RESIZE, this.onCropResize,
      constants.CROP_ADD, this.onCropAdd,
      constants.CROP_SAVE_START, this.onSaveStart,
      constants.CROP_SAVE_SUCCESS, this.onSaveSuccess,
      constants.CROP_PICK_START, this.onPickStart,
      constants.CROP_PICK_SUCCESS, this.onPickSuccess    
    );
github adobe-photoshop / spaces-design / test / spec / util / fluxxor-test-helper.js View on Github external
define(function (require, exports) {
    "use strict";

    var Fluxxor = require("fluxxor");

    var FluxController = require("js/fluxcontroller");

    var _dispatch = function (type, payload) {
        this.dispatcher.dispatch({ type: type, payload: payload });
    };

    var _bindTestActions = function () {
        this.bindActions.apply(this, arguments);
    };

    var TestStore = Fluxxor.createStore({});

    var setup = function () {
        var testStore = new TestStore(),
            testStores = { test: testStore },
            controller = new FluxController(testStores),
            flux = controller.flux;

        this.flux = flux;
        this.dispatch = _dispatch.bind(flux);
        this.bindTestAction = this.bindTestActions = _bindTestActions.bind(testStore);
    };

    exports.setup = setup;
});
github ervwalter / ewalnet-docpad / react / src / menuStores.js View on Github external
);
	},

	onLoadMenuExclusions() {
		this.loading = true;
		this.emit('change');
	},

	onLoadMenuExclusionsComplete(payload) {
		this.loading = false;
		this.exclusions = payload.exclusions;
		this.emit('change');
	}
});

var MenuStore = Fluxxor.createStore({
	initialize() {
		this.litefare = [];
		this.entree = [];
		this._exclusions = [];
		this._collection = [];
		this._games = [];
		this._rnd = seedrandom(moment().format('YYYY-MM-DD'));
		this.bindActions(
			constants.LoadMenuExclusionsComplete, this.onLoadMenuExclusionsComplete,
			constants.LoadCollectionComplete, this.onLoadCollectionComplete,
			constants.ReseedMenu, this.onReseedMenu
		);
	},

	onLoadCollectionComplete(payload) {
		this.waitFor(['CollectionStore'], collectionStore => {
github transistorsoft / background-geolocation-console / js / stores / DevicesStore.js View on Github external
var Fluxxor = require('fluxxor');
var constants = require('../constants/Constants');

/**
* Store
*/
var DevicesStore = Fluxxor.createStore({
  initialize: function() {
    this.data = [];

    this.bindActions(
      constants.LOAD_DEVICES, this.onLoad,
      constants.LOAD_DEVICES_SUCCESS, this.onLoadSuccess
    );
  },
  onLoad: function() {
    this.loading = true;
    this.emit("change");
  },
  onLoadSuccess: function(result) {
    this.loading = false;
    this.error = null;
github onefinestay / django-mediacat / static / js / stores / dragging.js View on Github external
 "use strict";

var Fluxxor = require('fluxxor');
var Immutable = require('immutable');

var constants = require('../constants');


var DraggingStore = Fluxxor.createStore({
  initialize: function(options) {
    this.bindActions(
      constants.DRAG_MEDIA_START, this.onDragMediaStart,
      constants.DRAG_MEDIA_MOVE, this.onDragMediaMove,
      constants.DRAG_MEDIA_END, this.onDragMediaStartEnd 
    );

    this.setMaxListeners(0);    
    this.state = Immutable.fromJS(options);
  },

  onDragMediaStart: function(payload) {
    this.state = this.state.withMutations(function(state) {
      state.set('top', payload.y).set('left', payload.x).set('draggingMedia', payload.media);
    });
    this.emit('change');
github svnlto / hoodie-react-fluxxor / www / js / app.js View on Github external
var hoodie = new global.Hoodie();
var React = require('react');
var Fluxxor = require('fluxxor');

var constants = {
  LOAD: 'LOAD',
  LOAD_SUCCESS: 'LOAD_SUCCESS',
  LOAD_ERROR: 'LOAD_ERROR',
  ADD_TODO: 'ADD_TODO',
  TOGGLE_TODO: 'TOGGLE_TODO',
  CLEAR_TODOS: 'CLEAR_TODOS'
};

var TodoStore = Fluxxor.createStore({
  initialize: function () {
    this.loading = false;
    this.error = null;
    this.todos = [];

    this.bindActions(
      constants.LOAD, this.onLoad,
      constants.LOAD_SUCCESS, this.onLoadSuccess,
      constants.LOAD_ERROR, this.onLoadError,
      constants.ADD_TODO, this.onAddTodo,
      constants.TOGGLE_TODO, this.onToggleTodo,
      constants.CLEAR_TODOS, this.onClearTodos
    );
  },

  onLoad: function (payload) {
github reapp / reapp-ui / repo_modules / brawndo / lib / createStore.js View on Github external
this.replaceState = newState => {
      this.state = newState;
      return this;
    };

    this.setPayload = newPayload => {
      this.payload = newPayload;
      return this;
    };

    mixinInitializers.forEach(initializer => initializer.call(this));
    this.bindActions(fluxxorActions);
  };

  var FluxxorStore = Fluxxor.createStore(Store);
  this.addStore(name, new FluxxorStore());
};
github concourse / concourse / assets / javascript / step_store.js View on Github external
var tree = require("./tree");

var EMIT_INTERVAL = 300;

var constants = {
  ADD_LOG: 'ADD_LOG',
  ADD_ERROR: 'ADD_ERROR',
  SET_STEP_RUNNING: 'SET_STEP_RUNNING',
  SET_STEP_ERRORED: 'SET_STEP_ERRORED',
  SET_STEP_VERSION_INFO: 'SET_STEP_VERSION_INFO',
  SET_STEP_SUCCESSFUL: 'SET_STEP_SUCCESSFUL',
  TOGGLE_STEP_LOGS: 'TOGGLE_STEP_LOGS',
  PRELOAD_INPUT: 'PRELOAD_INPUT',
};

var Store = Fluxxor.createStore({
  initialize: function() {
    this.steps = new concourse.StepData();

    this.preloadedInputs = Immutable.Map();

    this.bindActions(
      constants.ADD_LOG, this.onAddLog,
      constants.ADD_ERROR, this.onAddError,
      constants.SET_STEP_RUNNING, this.onSetStepRunning,
      constants.SET_STEP_ERRORED, this.onSetStepErrored,
      constants.SET_STEP_VERSION_INFO, this.onSetStepVersionInfo,
      constants.SET_STEP_SUCCESSFUL, this.onSetStepSuccessful,
      constants.TOGGLE_STEP_LOGS, this.onToggleStepLogs,
      constants.PRELOAD_INPUT, this.onPreloadInput
    );
github coinbay / CoinbayDEX / frontend / app / stores / MarketStore.js View on Github external
var _ = require("lodash");
var Fluxxor = require("fluxxor");

import bigRat from 'big-rational';

var constants = require("../js/constants");
var fixtures = require("../js/fixtures");
import utils from '../js/utils';

var MarketStore = Fluxxor.createStore({

  initialize: function(options) {
    this.market = options.market || {txs: [], prices: [], data: [], messages: []};
    this.markets = options.markets || [];
    this.favorites = [];
    this.progress = 0;
    this.lastMarketID = 0;
    this.lastOpenedMarketID = 0;
    this.loading = true;
    this.error = null;

    this.bindActions(
      constants.market.LOAD_MARKET, this.onLoadMarket,
      constants.market.LOAD_MARKETS, this.onLoadMarkets,
      constants.market.LOAD_MARKETS_FAIL, this.onLoadMarketsFail,
      constants.market.LOAD_MARKETS_SUCCESS, this.onLoadMarketsSuccess,
github coinbay / CoinbayDEX / frontend / app / stores / TradeStore.js View on Github external
var _ = require("lodash");
var Fluxxor = require("fluxxor");

var constants = require("../js/constants");

var TradeStore = Fluxxor.createStore({

  initialize: function(options) {
    this.title = "Trades";
    this.trades = options.trades || {buys: [], sells: [], tradeBuys: [], tradeSells: []};
    this.loading = true;
    this.updating = false;
    this.error = null;
    this.tradeIDs = [];
    this.percent = 0;
    this.progress = 0;
    this.type = 1;
    this.amount = null;
    this.price = null;
    this.total = null;
    this.filling = [];
    this.amountLeft = 0;

fluxxor

Flux architecture tools for React

MIT
Latest version published 9 years ago

Package Health Score

42 / 100
Full package analysis

Popular fluxxor functions