UNPKG

@artemelka/redux-store-injector

Version:

Utils for redux code-splitting.

46 lines (45 loc) 2.06 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import React, { PureComponent } from 'react'; import { InjectorContext } from './context'; import { injectReducers, removeReducers, injectSagas, removeSagas, } from './utils'; var StoreInjectorProvider = /** @class */ (function (_super) { __extends(StoreInjectorProvider, _super); function StoreInjectorProvider() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.setReducers = function (asyncReducers) { injectReducers({ asyncReducers: asyncReducers, store: _this.props.store }); }; _this.setSagas = function (asyncSagas) { injectSagas({ asyncSagas: asyncSagas, store: _this.props.store }); }; _this.ejectReducers = function (asyncReducers) { removeReducers({ asyncReducers: asyncReducers, store: _this.props.store }); }; _this.ejectSagas = function (asyncSagas) { removeSagas({ asyncSagas: asyncSagas, store: _this.props.store }); }; return _this; } StoreInjectorProvider.prototype.render = function () { return (React.createElement(InjectorContext.Provider, { value: { setReducers: this.setReducers, setSagas: this.setSagas, ejectReducers: this.ejectReducers, ejectSagas: this.ejectSagas, } }, this.props.children)); }; return StoreInjectorProvider; }(PureComponent)); export { StoreInjectorProvider };