Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
store.dispatchToken = this.register((payload) => {
var action = payload.action;
if (!store.hasOwnProperty('actions')) return;
var handler = store.actions[action.type];
var handlerName = action.type;
// the store doesn't care about this action
if (!handler) return;
if (typeof handler === 'string') {
handlerName = handler;
handler = store[handler];
}
invariant(
typeof handler === 'function',
'%s is not a function', handlerName
);
if (store.waitFor)
this.waitFor(store.waitFor);
handler.call(store, action);
});
}
registerStore(store) {
invariant(!store.dispatchToken, 'The store is already registered');
store.dispatchToken = this.register((payload) => {
var action = payload.action;
if (!store.hasOwnProperty('actions')) return;
var handler = store.actions[action.type];
var handlerName = action.type;
// the store doesn't care about this action
if (!handler) return;
if (typeof handler === 'string') {
handlerName = handler;
handler = store[handler];
}