UNPKG

@rxreact/context

Version:

Dependency-inject an RxJS signal graph into your React components

17 lines 733 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); var operators_1 = require("rxjs/operators"); function reducer(pairs, startWith) { var xs = pairs.map(function (_a, index) { var observable = _a[0], _mapper = _a[1]; return observable.pipe(operators_1.map(function (value) { return ({ index: index, payload: value }); })); }); return rxjs_1.merge.apply(void 0, xs).pipe(operators_1.scan(function (state, _a) { var index = _a.index, payload = _a.payload; var _b = pairs[index], f = _b[1]; return f(state, payload); }, startWith), operators_1.shareReplay(1)); } exports.reducer = reducer; //# sourceMappingURL=reducer.js.map