UNPKG

rxdeep

Version:
52 lines 2.46 kB
"use strict"; 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 __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.verified = exports.VerifiedState = void 0; var rxjs_1 = require("rxjs"); var operators_1 = require("rxjs/operators"); var state_1 = require("./state"); var reverse_1 = require("./reverse"); var take_until_completes_1 = require("./util/take-until-completes"); var VerifiedState = /** @class */ (function (_super) { __extends(VerifiedState, _super); function VerifiedState(state, verifier) { var _this = _super.call(this, state.value, rxjs_1.defer(function () { return rxjs_1.merge(state.downstream.pipe(take_until_completes_1.takeUntilCompletes(_this._bounce)), _this._bounce.pipe(operators_1.map(reverse_1.reverse), take_until_completes_1.takeUntilCompletes(state.downstream))); }), { next: function (change) { if (!verifier(change)) { _this._bounce.next(change); } else { state.upstream.next(change); } }, error: function (err) { return state.upstream.error(err); }, complete: function () { return _this._bounce.complete(); }, }) || this; _this.state = state; _this.verifier = verifier; _this._bounce = new rxjs_1.Subject(); return _this; } VerifiedState.prototype.bounce = function () { return rxjs_1.merge(this.downstream.pipe(operators_1.filter(function () { return false; }), take_until_completes_1.takeUntilCompletes(this._bounce)), this._bounce.pipe(take_until_completes_1.takeUntilCompletes(this.downstream))); }; return VerifiedState; }(state_1.State)); exports.VerifiedState = VerifiedState; function verified(state, verifier) { return new VerifiedState(state, verifier); } exports.verified = verified; //# sourceMappingURL=verified.js.map