UNPKG

triviality-redux

Version:
52 lines 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var redux_1 = require("redux"); var redux_devtools_extension_1 = require("redux-devtools-extension"); var redux_observable_1 = require("redux-observable"); var ReduxFeature = /** @class */ (function () { function ReduxFeature() { } ReduxFeature.prototype.registries = function () { var _this = this; return { reducers: function () { return {}; }, middleware: function () { return [_this.epicMiddleware()]; }, epics: function () { return []; }, enhancers: function () { return [_this.middlewareEnhancer()]; }, }; }; ReduxFeature.prototype.setup = function () { // Create store first for epicMiddleware. this.store(); this.epicMiddleware().run(this.rootEpic()); }; ReduxFeature.prototype.devToolsOptions = function () { return {}; }; ReduxFeature.prototype.store = function () { var composeEnhancers = redux_devtools_extension_1.composeWithDevTools(this.devToolsOptions()); var registries = this.registries(); return redux_1.createStore(redux_1.combineReducers(registries.reducers()), composeEnhancers.apply(void 0, registries.enhancers())); }; ReduxFeature.prototype.middlewareEnhancer = function () { var registries = this.registries(); return redux_1.applyMiddleware.apply(void 0, registries.middleware()); }; ReduxFeature.prototype.rootEpic = function () { return redux_observable_1.combineEpics.apply(void 0, this.registries().epics()); }; ReduxFeature.prototype.epicMiddleware = function () { return redux_observable_1.createEpicMiddleware(); }; return ReduxFeature; }()); exports.ReduxFeature = ReduxFeature; //# sourceMappingURL=ReduxFeature.js.map