UNPKG

redux-polling

Version:

Convenient way to support polling in your Redux app so you can focus on the business logic

38 lines (31 loc) 1.37 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _actions = require('./actions'); var _logic = require('./logic'); var logic = _interopRequireWildcard(_logic); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } exports.default = function (store) { return function (next) { return function (action) { if (!(0, _actions.isPollingAction)(action)) { return next(action); } switch (action.type) { case _actions.actionTypes.start: return logic.start(store, action, next); case _actions.actionTypes.stop: return logic.stop(store, action, next); case _actions.actionTypes.reset: return logic.reset(store, action, next); case _actions.actionTypes.request: return logic.request(store, action, next); case _actions.actionTypes.addEntries: return logic.addEntries(store, action, next); default: return false; } }; }; };