2 var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
9 return function (d, b) {
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15 Object.defineProperty(exports, "__esModule", { value: true });
16 var Subject_1 = require("../Subject");
17 var OuterSubscriber_1 = require("../OuterSubscriber");
18 var subscribeToResult_1 = require("../util/subscribeToResult");
19 function window(windowBoundaries) {
20 return function windowOperatorFunction(source) {
21 return source.lift(new WindowOperator(windowBoundaries));
24 exports.window = window;
25 var WindowOperator = (function () {
26 function WindowOperator(windowBoundaries) {
27 this.windowBoundaries = windowBoundaries;
29 WindowOperator.prototype.call = function (subscriber, source) {
30 var windowSubscriber = new WindowSubscriber(subscriber);
31 var sourceSubscription = source.subscribe(windowSubscriber);
32 if (!sourceSubscription.closed) {
33 windowSubscriber.add(subscribeToResult_1.subscribeToResult(windowSubscriber, this.windowBoundaries));
35 return sourceSubscription;
37 return WindowOperator;
39 var WindowSubscriber = (function (_super) {
40 __extends(WindowSubscriber, _super);
41 function WindowSubscriber(destination) {
42 var _this = _super.call(this, destination) || this;
43 _this.window = new Subject_1.Subject();
44 destination.next(_this.window);
47 WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
50 WindowSubscriber.prototype.notifyError = function (error, innerSub) {
53 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
56 WindowSubscriber.prototype._next = function (value) {
57 this.window.next(value);
59 WindowSubscriber.prototype._error = function (err) {
60 this.window.error(err);
61 this.destination.error(err);
63 WindowSubscriber.prototype._complete = function () {
64 this.window.complete();
65 this.destination.complete();
67 WindowSubscriber.prototype._unsubscribe = function () {
70 WindowSubscriber.prototype.openWindow = function () {
71 var prevWindow = this.window;
73 prevWindow.complete();
75 var destination = this.destination;
76 var newWindow = this.window = new Subject_1.Subject();
77 destination.next(newWindow);
79 return WindowSubscriber;
80 }(OuterSubscriber_1.OuterSubscriber));
81 //# sourceMappingURL=window.js.map