-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.js
28 lines (28 loc) · 1.26 KB
/
state.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var withLatestFrom_1 = require('rxjs/operator/withLatestFrom');
var scan_1 = require('rxjs/operator/scan');
var observeOn_1 = require('rxjs/operator/observeOn');
var queue_1 = require('rxjs/scheduler/queue');
var BehaviorSubject_1 = require('rxjs/BehaviorSubject');
var State = (function (_super) {
__extends(State, _super);
function State(_initialState, action$, reducer$) {
var _this = this;
_super.call(this, _initialState);
var actionInQueue$ = observeOn_1.observeOn.call(action$, queue_1.queue);
var actionAndReducer$ = withLatestFrom_1.withLatestFrom.call(actionInQueue$, reducer$);
var state$ = scan_1.scan.call(actionAndReducer$, function (state, _a) {
var action = _a[0], reducer = _a[1];
return reducer(state, action);
}, _initialState);
state$.subscribe(function (value) { return _this.next(value); });
}
return State;
}(BehaviorSubject_1.BehaviorSubject));
exports.State = State;
//# sourceMappingURL=state.js.map