1 | /** PURE_IMPORTS_START tslib,_Subject,_innerSubscribe PURE_IMPORTS_END */
|
---|
2 | import * as tslib_1 from "tslib";
|
---|
3 | import { Subject } from '../Subject';
|
---|
4 | import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
|
---|
5 | export function window(windowBoundaries) {
|
---|
6 | return function windowOperatorFunction(source) {
|
---|
7 | return source.lift(new WindowOperator(windowBoundaries));
|
---|
8 | };
|
---|
9 | }
|
---|
10 | var WindowOperator = /*@__PURE__*/ (function () {
|
---|
11 | function WindowOperator(windowBoundaries) {
|
---|
12 | this.windowBoundaries = windowBoundaries;
|
---|
13 | }
|
---|
14 | WindowOperator.prototype.call = function (subscriber, source) {
|
---|
15 | var windowSubscriber = new WindowSubscriber(subscriber);
|
---|
16 | var sourceSubscription = source.subscribe(windowSubscriber);
|
---|
17 | if (!sourceSubscription.closed) {
|
---|
18 | windowSubscriber.add(innerSubscribe(this.windowBoundaries, new SimpleInnerSubscriber(windowSubscriber)));
|
---|
19 | }
|
---|
20 | return sourceSubscription;
|
---|
21 | };
|
---|
22 | return WindowOperator;
|
---|
23 | }());
|
---|
24 | var WindowSubscriber = /*@__PURE__*/ (function (_super) {
|
---|
25 | tslib_1.__extends(WindowSubscriber, _super);
|
---|
26 | function WindowSubscriber(destination) {
|
---|
27 | var _this = _super.call(this, destination) || this;
|
---|
28 | _this.window = new Subject();
|
---|
29 | destination.next(_this.window);
|
---|
30 | return _this;
|
---|
31 | }
|
---|
32 | WindowSubscriber.prototype.notifyNext = function () {
|
---|
33 | this.openWindow();
|
---|
34 | };
|
---|
35 | WindowSubscriber.prototype.notifyError = function (error) {
|
---|
36 | this._error(error);
|
---|
37 | };
|
---|
38 | WindowSubscriber.prototype.notifyComplete = function () {
|
---|
39 | this._complete();
|
---|
40 | };
|
---|
41 | WindowSubscriber.prototype._next = function (value) {
|
---|
42 | this.window.next(value);
|
---|
43 | };
|
---|
44 | WindowSubscriber.prototype._error = function (err) {
|
---|
45 | this.window.error(err);
|
---|
46 | this.destination.error(err);
|
---|
47 | };
|
---|
48 | WindowSubscriber.prototype._complete = function () {
|
---|
49 | this.window.complete();
|
---|
50 | this.destination.complete();
|
---|
51 | };
|
---|
52 | WindowSubscriber.prototype._unsubscribe = function () {
|
---|
53 | this.window = null;
|
---|
54 | };
|
---|
55 | WindowSubscriber.prototype.openWindow = function () {
|
---|
56 | var prevWindow = this.window;
|
---|
57 | if (prevWindow) {
|
---|
58 | prevWindow.complete();
|
---|
59 | }
|
---|
60 | var destination = this.destination;
|
---|
61 | var newWindow = this.window = new Subject();
|
---|
62 | destination.next(newWindow);
|
---|
63 | };
|
---|
64 | return WindowSubscriber;
|
---|
65 | }(SimpleOuterSubscriber));
|
---|
66 | //# sourceMappingURL=window.js.map
|
---|