UNPKG

redux-fluorine

Version:

A Redux enhancer to manage groups of actions as observables (agendas)

43 lines (33 loc) 957 B
import filterActions from '../actions/filterActions'; function _ref2() { // NOTE: We don't need to do anything here } export default function executeAgenda(agenda, store) { var dispatch = store.dispatch; var getState = store.getState; var anchor = getState(); var actions = []; // Subscribe to the agenda and return the subscription function _ref() { dispatch(filterActions(anchor, actions)); } var sub = agenda.subscribe({ next: function next(action) { // Dispatch action normally and push it to our bucket dispatch(action); actions.push(action); }, error: function error(err) { console.error && console.error(err); // Instruct the reducer wrapper to recompute the state // without any actions inside the `actions` array if (actions.length) { setTimeout(_ref); } }, complete: _ref2 }); return { unsubscribe: sub.unsubscribe.bind(sub) }; }