Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var FluxService = function FluxService(immutableDefaults, $rootScope) {
this.stores = [];
this.dispatcherInstance = dispatchr.createDispatcher();
this.dispatcher = this.dispatcherInstance.createContext();
this.dispatch = function () {
if (registeredStores.length) {
console.warn('There are still stores not injected: ' + registeredStores.join(',') + '. Make sure to manually inject all stores before running any dispatches or set autoInjectStores to true.'); // eslint-disable-line no-console
}
this.dispatcher.dispatch.apply(this.dispatcher, arguments);
};
this.createStore = function (name, spec) {
var store = createStore(name, spec, immutableDefaults, this);
var storeInstance; // Create the exports object
store.exports = {};
this.dispatcherInstance.registerStore(store);
const FluxService = function(immutableDefaults, $rootScope) {
this.stores = []
this.dispatcherInstance = dispatchr.createDispatcher()
this.dispatcher = this.dispatcherInstance.createContext()
this.dispatch = function() {
if (registeredStores.length) {
console.warn(
'There are still stores not injected: ' +
registeredStores.join(',') +
'. Make sure to manually inject all stores before running any dispatches or set autoInjectStores to true.'
) // eslint-disable-line no-console
}
this.dispatcher.dispatch.apply(this.dispatcher, arguments)
}
this.createStore = function(name, spec) {
const store = createStore(name, spec, immutableDefaults, this)
let storeInstance
function Fluxible(options) {
debug('Fluxible instance instantiated', options);
options = options || {};
// Options
this._component = options.component;
this._componentActionErrorHandler =
options.componentActionErrorHandler || defaultComponentActionHandler;
this._plugins = [];
// Initialize dependencies
this._dispatcher = dispatchr.createDispatcher(options);
}
it('should not conflict with other instances of itself', function () {
var dispatcherA = dispatcher.createDispatcher({ stores: stores });
var dispatcherContextA = dispatcherA.createContext({});
var dispatcherB = dispatcher.createDispatcher({ stores: stores });
var dispatcherContextB = dispatcherB.createContext({});
var storeA = dispatcherContextA.getStore(PrivatesStore);
var storeB = dispatcherContextB.getStore(PrivatesStore);
expect(storeA.number).to.equal(50);
expect(storeB.number).to.equal(50);
dispatcherContextA.dispatch('TRIGGER', 100);
expect(storeA.number).to.equal(100);
expect(storeB.number).to.equal(50);
});
});
it('should not conflict with other instances of itself', function () {
var dispatcherA = dispatcher.createDispatcher({ stores: stores });
var dispatcherContextA = dispatcherA.createContext({});
var dispatcherB = dispatcher.createDispatcher({ stores: stores });
var dispatcherContextB = dispatcherB.createContext({});
var storeA = dispatcherContextA.getStore(PrivatesStore);
var storeB = dispatcherContextB.getStore(PrivatesStore);
expect(storeA.number).to.equal(50);
expect(storeB.number).to.equal(50);
dispatcherContextA.dispatch('TRIGGER', 100);
expect(storeA.number).to.equal(100);
expect(storeB.number).to.equal(50);
});
});
beforeEach(function () {
this.dispatcher = dispatcher.createDispatcher({ stores: stores });
this.dispatcherContext = this.dispatcher.createContext({});
});
},
additionalMethod() {}
});
class ExtendedStore extends BaseStore {
static handlers = {
ACTION_NAME: 'actionHandler'
};
actionHandler() {
this.emitChange();
}
}
const dispatcher = createDispatcher({
errorHandler(e, context) {
e.meta;
e.type;
e.message;
},
stores: [TestStore]
});
const context = dispatcher.createContext({});
context.dispatch('ACTION_NAME', {});
module.exports = function createMockActionContext(options) {
options = options || {};
options.mockActionContextClass = options.mockActionContextClass || MockActionContextClass;
options.stores = options.stores || [];
options.dispatcher = options.dispatcher || dispatchr.createDispatcher({
stores: options.stores
});
options.dispatcherContext = options.dispatcherContext || options.dispatcher.createContext();
return new options.mockActionContextClass(options.dispatcherContext);
};
* SOFTWARE.
*/
import dispatchr from 'dispatchr';
import stores from './stores';
import actions from './actions';
import { setImmediate } from 'setimmediate2';
import { UserAgent } from 'express-useragent/lib/express-useragent';
import { getCookieClient, setCookieClient } from './utils/cookie';
import { createId, removeCss } from './utils/styles';
import { map, reduce } from 'lodash';
import { siteName } from './config';
const
storeNames = map(stores, item => item.storeName),
dispatcher = dispatchr.createDispatcher({
stores
});
class Context {
constructor() {
this.dispatcher = dispatcher.createContext();
this.getStore = this.getStore.bind(this);
this.insertCss = this.insertCss.bind(this);
this.removeCss = this.removeCss.bind(this);
this.executeAction = this.executeAction.bind(this);
this.dispatch = this.dispatch.bind(this);
this.dehydrate = this.dehydrate.bind(this);
this.styles = {};
}
module.exports = function createMockComponentContext(options) {
options = options || {};
options.mockComponentContextClass = options.mockComponentContextClass || MockComponentContextClass;
options.stores = options.stores || [];
options.dispatcher = options.dispatcher || dispatchr.createDispatcher({
stores: options.stores
});
options.dispatcherContext = options.dispatcherContext || options.dispatcher.createContext();
return new options.mockComponentContextClass(options.dispatcherContext);
};