From 41d39e2ba3aa02cf2f8848a6d43d887df725bd8c Mon Sep 17 00:00:00 2001 From: Tetsuharu OHZEKI Date: Wed, 30 Dec 2015 17:05:07 +0900 Subject: [PATCH] refactor(subscriber): Make a derived `Subscriber`s' internal methods protected --- src/observable/ConnectableObservable.ts | 6 +++--- src/observable/forkJoin.ts | 4 ++-- src/operator/buffer.ts | 2 +- src/operator/bufferCount.ts | 4 ++-- src/operator/bufferTime.ts | 6 +++--- src/operator/bufferToggle.ts | 18 +++++++++--------- src/operator/bufferWhen.ts | 4 ++-- src/operator/combineLatest-support.ts | 4 ++-- src/operator/count.ts | 4 ++-- src/operator/debounce.ts | 4 ++-- src/operator/debounceTime.ts | 4 ++-- src/operator/defaultIfEmpty.ts | 4 ++-- src/operator/delay.ts | 6 +++--- src/operator/dematerialize.ts | 2 +- src/operator/distinctUntilChanged.ts | 2 +- src/operator/do.ts | 6 +++--- src/operator/elementAt.ts | 4 ++-- src/operator/every.ts | 4 ++-- src/operator/exhaust.ts | 4 ++-- src/operator/exhaustMap.ts | 4 ++-- src/operator/expand-support.ts | 4 ++-- src/operator/filter.ts | 2 +- src/operator/find-support.ts | 4 ++-- src/operator/first.ts | 4 ++-- src/operator/groupBy.ts | 12 ++++++------ src/operator/ignoreElements.ts | 2 +- src/operator/isEmpty.ts | 4 ++-- src/operator/last.ts | 4 ++-- src/operator/map.ts | 2 +- src/operator/mapTo.ts | 2 +- src/operator/materialize.ts | 6 +++--- src/operator/mergeAll-support.ts | 4 ++-- src/operator/mergeMap-support.ts | 4 ++-- src/operator/mergeMapTo-support.ts | 5 +++-- src/operator/mergeScan.ts | 4 ++-- src/operator/observeOn-support.ts | 6 +++--- src/operator/reduce-support.ts | 4 ++-- src/operator/sample.ts | 2 +- src/operator/sampleTime.ts | 2 +- src/operator/scan.ts | 2 +- src/operator/single.ts | 4 ++-- src/operator/skip.ts | 2 +- src/operator/skipUntil.ts | 4 ++-- src/operator/skipWhile.ts | 2 +- src/operator/switch.ts | 4 ++-- src/operator/switchMap.ts | 4 ++-- src/operator/switchMapTo.ts | 4 ++-- src/operator/take.ts | 2 +- src/operator/takeWhile.ts | 2 +- src/operator/throttle.ts | 2 +- src/operator/throttleTime.ts | 2 +- src/operator/timeInterval.ts | 2 +- src/operator/timeout.ts | 6 +++--- src/operator/timeoutWith.ts | 6 +++--- src/operator/toArray.ts | 4 ++-- src/operator/window.ts | 24 ++++++++++++++++-------- src/operator/windowCount.ts | 6 +++--- src/operator/windowTime.ts | 6 +++--- src/operator/windowToggle.ts | 6 +++--- src/operator/windowWhen.ts | 12 ++++++------ src/operator/withLatestFrom.ts | 2 +- src/operator/zip-support.ts | 4 ++-- 62 files changed, 147 insertions(+), 138 deletions(-) diff --git a/src/observable/ConnectableObservable.ts b/src/observable/ConnectableObservable.ts index e45cde398b..561c20c670 100644 --- a/src/observable/ConnectableObservable.ts +++ b/src/observable/ConnectableObservable.ts @@ -83,16 +83,16 @@ class RefCountSubscriber extends Subscriber { destination.add(this); } - _next(value: T) { + protected _next(value: T) { this.destination.next(value); } - _error(err: any) { + protected _error(err: any) { this._resetConnectable(); this.destination.error(err); } - _complete() { + protected _complete() { this._resetConnectable(); this.destination.complete(); } diff --git a/src/observable/forkJoin.ts b/src/observable/forkJoin.ts index efc6a88808..3d34bb9771 100644 --- a/src/observable/forkJoin.ts +++ b/src/observable/forkJoin.ts @@ -59,11 +59,11 @@ class AllSubscriber extends Subscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { this._value = value; } - _complete(): void { + protected _complete(): void { const destination = this.destination; if (this._value == null) { diff --git a/src/operator/buffer.ts b/src/operator/buffer.ts index 3089acf7b4..5db05eee40 100644 --- a/src/operator/buffer.ts +++ b/src/operator/buffer.ts @@ -40,7 +40,7 @@ class BufferSubscriber extends OuterSubscriber { this.add(subscribeToResult(this, closingNotifier)); } - _next(value: T) { + protected _next(value: T) { this.buffer.push(value); } diff --git a/src/operator/bufferCount.ts b/src/operator/bufferCount.ts index eaba7519ca..3a6e2af0db 100644 --- a/src/operator/bufferCount.ts +++ b/src/operator/bufferCount.ts @@ -39,7 +39,7 @@ class BufferCountSubscriber extends Subscriber { super(destination); } - _next(value: T) { + protected _next(value: T) { const count = (this.count += 1); const destination = this.destination; const bufferSize = this.bufferSize; @@ -66,7 +66,7 @@ class BufferCountSubscriber extends Subscriber { } } - _complete() { + protected _complete() { const destination = this.destination; const buffers = this.buffers; while (buffers.length > 0) { diff --git a/src/operator/bufferTime.ts b/src/operator/bufferTime.ts index 3dda3ae14e..8f45c9342f 100644 --- a/src/operator/bufferTime.ts +++ b/src/operator/bufferTime.ts @@ -59,7 +59,7 @@ class BufferTimeSubscriber extends Subscriber { } } - _next(value: T) { + protected _next(value: T) { const buffers = this.buffers; const len = buffers.length; for (let i = 0; i < len; i++) { @@ -67,12 +67,12 @@ class BufferTimeSubscriber extends Subscriber { } } - _error(err: any) { + protected _error(err: any) { this.buffers.length = 0; super._error(err); } - _complete() { + protected _complete() { const { buffers, destination } = this; while (buffers.length > 0) { destination.next(buffers.shift()); diff --git a/src/operator/bufferToggle.ts b/src/operator/bufferToggle.ts index 30d45373b0..695c46ea88 100644 --- a/src/operator/bufferToggle.ts +++ b/src/operator/bufferToggle.ts @@ -50,7 +50,7 @@ class BufferToggleSubscriber extends Subscriber { this.add(this.openings.subscribe(new BufferToggleOpeningsSubscriber(this))); } - _next(value: T) { + protected _next(value: T) { const contexts = this.contexts; const len = contexts.length; for (let i = 0; i < len; i++) { @@ -58,7 +58,7 @@ class BufferToggleSubscriber extends Subscriber { } } - _error(err: any) { + protected _error(err: any) { const contexts = this.contexts; while (contexts.length > 0) { const context = contexts.shift(); @@ -70,7 +70,7 @@ class BufferToggleSubscriber extends Subscriber { super._error(err); } - _complete() { + protected _complete() { const contexts = this.contexts; while (contexts.length > 0) { const context = contexts.shift(); @@ -121,15 +121,15 @@ class BufferToggleOpeningsSubscriber extends Subscriber { super(null); } - _next(value: O) { + protected _next(value: O) { this.parent.openBuffer(value); } - _error(err: any) { + protected _error(err: any) { this.parent.error(err); } - _complete() { + protected _complete() { // noop } } @@ -140,15 +140,15 @@ class BufferToggleClosingsSubscriber extends Subscriber { super(null); } - _next() { + protected _next() { this.parent.closeBuffer(this.context); } - _error(err: any) { + protected _error(err: any) { this.parent.error(err); } - _complete() { + protected _complete() { this.parent.closeBuffer(this.context); } } diff --git a/src/operator/bufferWhen.ts b/src/operator/bufferWhen.ts index 641cd97f04..220869d55d 100644 --- a/src/operator/bufferWhen.ts +++ b/src/operator/bufferWhen.ts @@ -43,11 +43,11 @@ class BufferWhenSubscriber extends OuterSubscriber { this.openBuffer(); } - _next(value: T) { + protected _next(value: T) { this.buffer.push(value); } - _complete() { + protected _complete() { const buffer = this.buffer; if (buffer) { this.destination.next(buffer); diff --git a/src/operator/combineLatest-support.ts b/src/operator/combineLatest-support.ts index b9f87cea30..5c9ce1d459 100644 --- a/src/operator/combineLatest-support.ts +++ b/src/operator/combineLatest-support.ts @@ -25,13 +25,13 @@ export class CombineLatestSubscriber extends OuterSubscriber { super(destination); } - _next(observable: any) { + protected _next(observable: any) { const toRespond = this.toRespond; toRespond.push(toRespond.length); this.observables.push(observable); } - _complete() { + protected _complete() { const observables = this.observables; const len = observables.length; if (len === 0) { diff --git a/src/operator/count.ts b/src/operator/count.ts index f562b164ae..6ccc315e4e 100644 --- a/src/operator/count.ts +++ b/src/operator/count.ts @@ -43,7 +43,7 @@ class CountSubscriber extends Subscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { const predicate = this.predicate; let passed: any = true; if (predicate) { @@ -58,7 +58,7 @@ class CountSubscriber extends Subscriber { } } - _complete(): void { + protected _complete(): void { this.destination.next(this.count); this.destination.complete(); } diff --git a/src/operator/debounce.ts b/src/operator/debounce.ts index 10f4cbeb49..581d3b01e8 100644 --- a/src/operator/debounce.ts +++ b/src/operator/debounce.ts @@ -43,7 +43,7 @@ class DebounceSubscriber extends OuterSubscriber { super(destination); } - _next(value: T) { + protected _next(value: T) { let subscription = this.durationSubscription; const duration = tryCatch(this.durationSelector)(value); @@ -63,7 +63,7 @@ class DebounceSubscriber extends OuterSubscriber { } } - _complete() { + protected _complete() { this.emitValue(); this.destination.complete(); } diff --git a/src/operator/debounceTime.ts b/src/operator/debounceTime.ts index 7cec930d98..4d03447e61 100644 --- a/src/operator/debounceTime.ts +++ b/src/operator/debounceTime.ts @@ -41,14 +41,14 @@ class DebounceTimeSubscriber extends Subscriber { super(destination); } - _next(value: T) { + protected _next(value: T) { this.clearDebounce(); this.lastValue = value; this.hasValue = true; this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this)); } - _complete() { + protected _complete() { this.debouncedNext(); this.destination.complete(); } diff --git a/src/operator/defaultIfEmpty.ts b/src/operator/defaultIfEmpty.ts index 31278dd3bf..3c80db2a6a 100644 --- a/src/operator/defaultIfEmpty.ts +++ b/src/operator/defaultIfEmpty.ts @@ -28,12 +28,12 @@ class DefaultIfEmptySubscriber extends Subscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { this.isEmpty = false; this.destination.next(value); } - _complete(): void { + protected _complete(): void { if (this.isEmpty) { this.destination.next(this.defaultValue); } diff --git a/src/operator/delay.ts b/src/operator/delay.ts index 9ee969de12..f462165ec3 100644 --- a/src/operator/delay.ts +++ b/src/operator/delay.ts @@ -80,17 +80,17 @@ class DelaySubscriber extends Subscriber { } } - _next(value: T) { + protected _next(value: T) { this.scheduleNotification(Notification.createNext(value)); } - _error(err: any) { + protected _error(err: any) { this.errored = true; this.queue = []; this.destination.error(err); } - _complete() { + protected _complete() { this.scheduleNotification(Notification.createComplete()); } } diff --git a/src/operator/dematerialize.ts b/src/operator/dematerialize.ts index a96fbd1ba3..fab25f365b 100644 --- a/src/operator/dematerialize.ts +++ b/src/operator/dematerialize.ts @@ -22,7 +22,7 @@ class DeMaterializeSubscriber> extends Subscriber super(destination); } - _next(value: T) { + protected _next(value: T) { value.observe(this.destination); } } diff --git a/src/operator/distinctUntilChanged.ts b/src/operator/distinctUntilChanged.ts index 030796622c..87536df10b 100644 --- a/src/operator/distinctUntilChanged.ts +++ b/src/operator/distinctUntilChanged.ts @@ -44,7 +44,7 @@ class DistinctUntilChangedSubscriber extends Subscriber { return x === y; } - _next(value: T): void { + protected _next(value: T): void { const keySelector = this.keySelector; let key: any = value; diff --git a/src/operator/do.ts b/src/operator/do.ts index 0fbf3cb51c..a855410b19 100644 --- a/src/operator/do.ts +++ b/src/operator/do.ts @@ -58,7 +58,7 @@ class DoSubscriber extends Subscriber { this.__complete = complete; } - _next(x: T) { + protected _next(x: T) { const result = tryCatch(this.__next)(x); if (result === errorObject) { this.destination.error(errorObject.e); @@ -67,7 +67,7 @@ class DoSubscriber extends Subscriber { } } - _error(e: any) { + protected _error(e: any) { const result = tryCatch(this.__error)(e); if (result === errorObject) { this.destination.error(errorObject.e); @@ -76,7 +76,7 @@ class DoSubscriber extends Subscriber { } } - _complete() { + protected _complete() { const result = tryCatch(this.__complete)(); if (result === errorObject) { this.destination.error(errorObject.e); diff --git a/src/operator/elementAt.ts b/src/operator/elementAt.ts index 907afe98f3..84a2968b50 100644 --- a/src/operator/elementAt.ts +++ b/src/operator/elementAt.ts @@ -33,14 +33,14 @@ class ElementAtSubscriber extends Subscriber { super(destination); } - _next(x: T) { + protected _next(x: T) { if (this.index-- === 0) { this.destination.next(x); this.destination.complete(); } } - _complete() { + protected _complete() { const destination = this.destination; if (this.index >= 0) { if (typeof this.defaultValue !== 'undefined') { diff --git a/src/operator/every.ts b/src/operator/every.ts index 597e2f3001..7488ba3790 100644 --- a/src/operator/every.ts +++ b/src/operator/every.ts @@ -65,7 +65,7 @@ class EverySubscriber extends Subscriber { this.destination.complete(); } - _next(value: T): void { + protected _next(value: T): void { const result = tryCatch(this.predicate).call(this.thisArg || this, value, this.index++, this.source); if (result === errorObject) { @@ -75,7 +75,7 @@ class EverySubscriber extends Subscriber { } } - _complete(): void { + protected _complete(): void { this.notifyComplete(true); } } diff --git a/src/operator/exhaust.ts b/src/operator/exhaust.ts index 366b14b6d6..070a135dec 100644 --- a/src/operator/exhaust.ts +++ b/src/operator/exhaust.ts @@ -30,14 +30,14 @@ class SwitchFirstSubscriber extends OuterSubscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { if (!this.hasSubscription) { this.hasSubscription = true; this.add(subscribeToResult(this, value)); } } - _complete(): void { + protected _complete(): void { this.hasCompleted = true; if (!this.hasSubscription) { this.destination.complete(); diff --git a/src/operator/exhaustMap.ts b/src/operator/exhaustMap.ts index 33b5019020..830538437d 100644 --- a/src/operator/exhaustMap.ts +++ b/src/operator/exhaustMap.ts @@ -43,7 +43,7 @@ class SwitchFirstMapSubscriber extends OuterSubscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { if (!this.hasSubscription) { const index = this.index++; const destination = this.destination; @@ -57,7 +57,7 @@ class SwitchFirstMapSubscriber extends OuterSubscriber { } } - _complete(): void { + protected _complete(): void { this.hasCompleted = true; if (!this.hasSubscription) { this.destination.complete(); diff --git a/src/operator/expand-support.ts b/src/operator/expand-support.ts index 598c92e148..6ea6e5628f 100644 --- a/src/operator/expand-support.ts +++ b/src/operator/expand-support.ts @@ -39,7 +39,7 @@ export class ExpandSubscriber extends OuterSubscriber { subscriber.subscribeToProjection(result, value, index); } - _next(value: any): void { + protected _next(value: any): void { const destination = this.destination; if (destination.isUnsubscribed) { @@ -73,7 +73,7 @@ export class ExpandSubscriber extends OuterSubscriber { } } - _complete(): void { + protected _complete(): void { this.hasCompleted = true; if (this.hasCompleted && this.active === 0) { this.destination.complete(); diff --git a/src/operator/filter.ts b/src/operator/filter.ts index cf13439293..7cdee8fd37 100644 --- a/src/operator/filter.ts +++ b/src/operator/filter.ts @@ -35,7 +35,7 @@ class FilterSubscriber extends Subscriber { this.select = select; } - _next(x: T) { + protected _next(x: T) { const result = tryCatch(this.select).call(this.thisArg || this, x, this.count++); if (result === errorObject) { this.destination.error(errorObject.e); diff --git a/src/operator/find-support.ts b/src/operator/find-support.ts index bc9866f4a1..4f48fff624 100644 --- a/src/operator/find-support.ts +++ b/src/operator/find-support.ts @@ -35,7 +35,7 @@ export class FindValueSubscriber extends Subscriber { destination.complete(); } - _next(value: T): void { + protected _next(value: T): void { const { predicate, thisArg } = this; const index = this.index++; const result = tryCatch(predicate).call(thisArg || this, value, index, this.source); @@ -46,7 +46,7 @@ export class FindValueSubscriber extends Subscriber { } } - _complete(): void { + protected _complete(): void { this.notifyComplete(this.yieldIndex ? -1 : undefined); } } \ No newline at end of file diff --git a/src/operator/first.ts b/src/operator/first.ts index c2fbffaae5..d80036ddf7 100644 --- a/src/operator/first.ts +++ b/src/operator/first.ts @@ -41,7 +41,7 @@ class FirstSubscriber extends Subscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { const { destination, predicate, resultSelector } = this; const index = this.index++; let passed: any = true; @@ -68,7 +68,7 @@ class FirstSubscriber extends Subscriber { } } - _complete(): void { + protected _complete(): void { const destination = this.destination; if (!this.hasCompleted && typeof this.defaultValue !== 'undefined') { destination.next(this.defaultValue); diff --git a/src/operator/groupBy.ts b/src/operator/groupBy.ts index 6e6fb615cd..ccb5b6ad3d 100644 --- a/src/operator/groupBy.ts +++ b/src/operator/groupBy.ts @@ -45,7 +45,7 @@ class GroupBySubscriber extends Subscriber { this.add(destination); } - _next(x: T): void { + protected _next(x: T): void { let key = tryCatch(this.keySelector)(x); if (key === errorObject) { this.error(errorObject.e); @@ -89,7 +89,7 @@ class GroupBySubscriber extends Subscriber { } } - _error(err: any): void { + protected _error(err: any): void { const groups = this.groups; if (groups) { groups.forEach((group, key) => { @@ -100,7 +100,7 @@ class GroupBySubscriber extends Subscriber { this.destination.error(err); } - _complete(): void { + protected _complete(): void { const groups = this.groups; if (groups) { groups.forEach((group, key) => { @@ -123,17 +123,17 @@ class GroupDurationSubscriber extends Subscriber { super(); } - _next(value: T): void { + protected _next(value: T): void { this.group.complete(); this.parent.removeGroup(this.key); } - _error(err: any): void { + protected _error(err: any): void { this.group.error(err); this.parent.removeGroup(this.key); } - _complete(): void { + protected _complete(): void { this.group.complete(); this.parent.removeGroup(this.key); } diff --git a/src/operator/ignoreElements.ts b/src/operator/ignoreElements.ts index 3499dcf31a..b5ff0e2b0b 100644 --- a/src/operator/ignoreElements.ts +++ b/src/operator/ignoreElements.ts @@ -14,7 +14,7 @@ class IgnoreElementsOperator implements Operator { } class IgnoreElementsSubscriber extends Subscriber { - _next(unused: T): void { + protected _next(unused: T): void { noop(); } } diff --git a/src/operator/isEmpty.ts b/src/operator/isEmpty.ts index 4f18cdde65..1a97f6a153 100644 --- a/src/operator/isEmpty.ts +++ b/src/operator/isEmpty.ts @@ -25,11 +25,11 @@ class IsEmptySubscriber extends Subscriber { destination.complete(); } - _next(value: boolean) { + protected _next(value: boolean) { this.notifyComplete(false); } - _complete() { + protected _complete() { this.notifyComplete(true); } } diff --git a/src/operator/last.ts b/src/operator/last.ts index 7aef0e74dd..bd51279866 100644 --- a/src/operator/last.ts +++ b/src/operator/last.ts @@ -40,7 +40,7 @@ class LastSubscriber extends Subscriber { } } - _next(value: T): void { + protected _next(value: T): void { const { predicate, resultSelector, destination } = this; const index = this.index++; @@ -70,7 +70,7 @@ class LastSubscriber extends Subscriber { } } - _complete(): void { + protected _complete(): void { const destination = this.destination; if (this.hasValue) { destination.next(this.lastValue); diff --git a/src/operator/map.ts b/src/operator/map.ts index 52c3f89aeb..d4bb3de820 100644 --- a/src/operator/map.ts +++ b/src/operator/map.ts @@ -37,7 +37,7 @@ class MapSubscriber extends Subscriber { super(destination); } - _next(x: T) { + protected _next(x: T) { const result = tryCatch(this.project).call(this.thisArg || this, x, this.count++); if (result === errorObject) { this.error(errorObject.e); diff --git a/src/operator/mapTo.ts b/src/operator/mapTo.ts index cf9cc5affd..7b02b1ff81 100644 --- a/src/operator/mapTo.ts +++ b/src/operator/mapTo.ts @@ -33,7 +33,7 @@ class MapToSubscriber extends Subscriber { this.value = value; } - _next(x: T) { + protected _next(x: T) { this.destination.next(this.value); } } diff --git a/src/operator/materialize.ts b/src/operator/materialize.ts index c937a2fc55..48a8e776f2 100644 --- a/src/operator/materialize.ts +++ b/src/operator/materialize.ts @@ -18,17 +18,17 @@ class MaterializeSubscriber extends Subscriber { super(destination); } - _next(value: T) { + protected _next(value: T) { this.destination.next(Notification.createNext(value)); } - _error(err: any) { + protected _error(err: any) { const destination = this.destination; destination.next(Notification.createError(err)); destination.complete(); } - _complete() { + protected _complete() { const destination = this.destination; destination.next(Notification.createComplete()); destination.complete(); diff --git a/src/operator/mergeAll-support.ts b/src/operator/mergeAll-support.ts index e5f866c07d..a65bac793a 100644 --- a/src/operator/mergeAll-support.ts +++ b/src/operator/mergeAll-support.ts @@ -23,7 +23,7 @@ export class MergeAllSubscriber extends OuterSubscriber, T> { super(destination); } - _next(observable: Observable) { + protected _next(observable: Observable) { if (this.active < this.concurrent) { if (observable._isScalar) { this.destination.next((observable).value); @@ -36,7 +36,7 @@ export class MergeAllSubscriber extends OuterSubscriber, T> { } } - _complete() { + protected _complete() { this.hasCompleted = true; if (this.active === 0 && this.buffer.length === 0) { this.destination.complete(); diff --git a/src/operator/mergeMap-support.ts b/src/operator/mergeMap-support.ts index 5828f1380f..a8c9b8a303 100644 --- a/src/operator/mergeMap-support.ts +++ b/src/operator/mergeMap-support.ts @@ -33,7 +33,7 @@ export class MergeMapSubscriber extends OuterSubscriber { super(destination); } - _next(value: any): void { + protected _next(value: any): void { if (this.active < this.concurrent) { const index = this.index++; const ish = tryCatch(this.project)(value, index); @@ -53,7 +53,7 @@ export class MergeMapSubscriber extends OuterSubscriber { this.add(subscribeToResult(this, ish, value, index)); } - _complete(): void { + protected _complete(): void { this.hasCompleted = true; if (this.active === 0 && this.buffer.length === 0) { this.destination.complete(); diff --git a/src/operator/mergeMapTo-support.ts b/src/operator/mergeMapTo-support.ts index e0752e698f..491013faa4 100644 --- a/src/operator/mergeMapTo-support.ts +++ b/src/operator/mergeMapTo-support.ts @@ -31,7 +31,8 @@ export class MergeMapToSubscriber extends OuterSubscriber { private concurrent: number = Number.POSITIVE_INFINITY) { super(destination); } - _next(value: any): void { + + protected _next(value: any): void { if (this.active < this.concurrent) { const resultSelector = this.resultSelector; const index = this.index++; @@ -53,7 +54,7 @@ export class MergeMapToSubscriber extends OuterSubscriber { this.add(subscribeToResult(this, ish, value, index)); } - _complete(): void { + protected _complete(): void { this.hasCompleted = true; if (this.active === 0 && this.buffer.length === 0) { this.destination.complete(); diff --git a/src/operator/mergeScan.ts b/src/operator/mergeScan.ts index 318696f784..28fb5c969e 100644 --- a/src/operator/mergeScan.ts +++ b/src/operator/mergeScan.ts @@ -40,7 +40,7 @@ export class MergeScanSubscriber extends OuterSubscriber { super(destination); } - _next(value: any): void { + protected _next(value: any): void { if (this.active < this.concurrent) { const index = this.index++; const ish = tryCatch(this.project)(this.acc, value); @@ -60,7 +60,7 @@ export class MergeScanSubscriber extends OuterSubscriber { this.add(subscribeToResult(this, ish, value, index)); } - _complete(): void { + protected _complete(): void { this.hasCompleted = true; if (this.active === 0 && this.buffer.length === 0) { if (this.hasValue === false) { diff --git a/src/operator/observeOn-support.ts b/src/operator/observeOn-support.ts index 7e3ff5f581..91af4fa700 100644 --- a/src/operator/observeOn-support.ts +++ b/src/operator/observeOn-support.ts @@ -30,15 +30,15 @@ export class ObserveOnSubscriber extends Subscriber { new ObserveOnMessage(notification, this.destination))); } - _next(value: T): void { + protected _next(value: T): void { this.scheduleMessage(Notification.createNext(value)); } - _error(err: any): void { + protected _error(err: any): void { this.scheduleMessage(Notification.createError(err)); } - _complete(): void { + protected _complete(): void { this.scheduleMessage(Notification.createComplete()); } } diff --git a/src/operator/reduce-support.ts b/src/operator/reduce-support.ts index ce7f57c662..aae0a73aa8 100644 --- a/src/operator/reduce-support.ts +++ b/src/operator/reduce-support.ts @@ -27,7 +27,7 @@ export class ReduceSubscriber extends Subscriber { this.hasSeed = typeof seed !== 'undefined'; } - _next(x: T) { + protected _next(x: T) { if (this.hasValue || (this.hasValue = this.hasSeed)) { const result = tryCatch(this.project).call(this, this.acc, x); if (result === errorObject) { @@ -41,7 +41,7 @@ export class ReduceSubscriber extends Subscriber { } } - _complete() { + protected _complete() { if (this.hasValue || this.hasSeed) { this.destination.next(this.acc); } diff --git a/src/operator/sample.ts b/src/operator/sample.ts index 1663b25515..42459f5d24 100644 --- a/src/operator/sample.ts +++ b/src/operator/sample.ts @@ -27,7 +27,7 @@ class SampleSubscriber extends OuterSubscriber { this.add(subscribeToResult(this, notifier)); } - _next(value: T) { + protected _next(value: T) { this.value = value; this.hasValue = true; } diff --git a/src/operator/sampleTime.ts b/src/operator/sampleTime.ts index b331aab229..ec881dc76a 100644 --- a/src/operator/sampleTime.ts +++ b/src/operator/sampleTime.ts @@ -26,7 +26,7 @@ class SampleTimeSubscriber extends Subscriber { this.add(scheduler.schedule(dispatchNotification, delay, { subscriber: this, delay })); } - _next(value: T) { + protected _next(value: T) { this.lastValue = value; this.hasValue = true; } diff --git a/src/operator/scan.ts b/src/operator/scan.ts index 7ea94df168..03a42dc8a6 100644 --- a/src/operator/scan.ts +++ b/src/operator/scan.ts @@ -46,7 +46,7 @@ class ScanSubscriber extends Subscriber { this.accumulatorSet = typeof seed !== 'undefined'; } - _next(value: T): void { + protected _next(value: T): void { if (!this.accumulatorSet) { this.seed = value; this.destination.next(value); diff --git a/src/operator/single.ts b/src/operator/single.ts index 6c7a61c3f4..fa5220b853 100644 --- a/src/operator/single.ts +++ b/src/operator/single.ts @@ -41,7 +41,7 @@ class SingleSubscriber extends Subscriber { } } - _next(value: T): void { + protected _next(value: T): void { const predicate = this.predicate; const currentIndex = this.index++; @@ -57,7 +57,7 @@ class SingleSubscriber extends Subscriber { } } - _complete(): void { + protected _complete(): void { const destination = this.destination; if (this.index > 0) { diff --git a/src/operator/skip.ts b/src/operator/skip.ts index 214c1089a1..96c48a6450 100644 --- a/src/operator/skip.ts +++ b/src/operator/skip.ts @@ -22,7 +22,7 @@ class SkipSubscriber extends Subscriber { super(destination); } - _next(x: T) { + protected _next(x: T) { if (++this.count > this.total) { this.destination.next(x); } diff --git a/src/operator/skipUntil.ts b/src/operator/skipUntil.ts index c368283790..2780387f4a 100644 --- a/src/operator/skipUntil.ts +++ b/src/operator/skipUntil.ts @@ -29,13 +29,13 @@ class SkipUntilSubscriber extends OuterSubscriber { this.add(subscribeToResult(this, notifier)); } - _next(value: T) { + protected _next(value: T) { if (this.hasValue) { super._next(value); } } - _complete() { + protected _complete() { if (this.isInnerStopped) { super._complete(); } else { diff --git a/src/operator/skipWhile.ts b/src/operator/skipWhile.ts index 11564e49ed..b33104d287 100644 --- a/src/operator/skipWhile.ts +++ b/src/operator/skipWhile.ts @@ -26,7 +26,7 @@ class SkipWhileSubscriber extends Subscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { const destination = this.destination; if (this.skipping === true) { const index = this.index++; diff --git a/src/operator/switch.ts b/src/operator/switch.ts index 30f184549e..f024c37048 100644 --- a/src/operator/switch.ts +++ b/src/operator/switch.ts @@ -23,13 +23,13 @@ class SwitchSubscriber extends OuterSubscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { this.unsubscribeInner(); this.active++; this.add(this.innerSubscription = subscribeToResult(this, value)); } - _complete(): void { + protected _complete(): void { this.hasCompleted = true; if (this.active === 0) { this.destination.complete(); diff --git a/src/operator/switchMap.ts b/src/operator/switchMap.ts index 05c9309bae..915ea63e2a 100644 --- a/src/operator/switchMap.ts +++ b/src/operator/switchMap.ts @@ -36,7 +36,7 @@ class SwitchMapSubscriber extends OuterSubscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { const index = this.index++; const destination = this.destination; let result = tryCatch(this.project)(value, index); @@ -51,7 +51,7 @@ class SwitchMapSubscriber extends OuterSubscriber { } } - _complete(): void { + protected _complete(): void { const {innerSubscription} = this; if (!innerSubscription || innerSubscription.isUnsubscribed) { super._complete(); diff --git a/src/operator/switchMapTo.ts b/src/operator/switchMapTo.ts index 0cbf66953e..2cdd3d1bac 100644 --- a/src/operator/switchMapTo.ts +++ b/src/operator/switchMapTo.ts @@ -36,7 +36,7 @@ class SwitchMapToSubscriber extends OuterSubscriber { super(destination); } - _next(value: any) { + protected _next(value: any) { const innerSubscription = this.innerSubscription; if (innerSubscription) { innerSubscription.unsubscribe(); @@ -44,7 +44,7 @@ class SwitchMapToSubscriber extends OuterSubscriber { this.add(this.innerSubscription = subscribeToResult(this, this.inner, value, this.index++)); } - _complete() { + protected _complete() { const {innerSubscription} = this; if (!innerSubscription || innerSubscription.isUnsubscribed) { super._complete(); diff --git a/src/operator/take.ts b/src/operator/take.ts index e1374d2a65..8dcd080286 100644 --- a/src/operator/take.ts +++ b/src/operator/take.ts @@ -31,7 +31,7 @@ class TakeSubscriber extends Subscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { const total = this.total; if (++this.count <= total) { this.destination.next(value); diff --git a/src/operator/takeWhile.ts b/src/operator/takeWhile.ts index 95798ee7c0..195bad0693 100644 --- a/src/operator/takeWhile.ts +++ b/src/operator/takeWhile.ts @@ -25,7 +25,7 @@ class TakeWhileSubscriber extends Subscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { const destination = this.destination; const result = tryCatch(this.predicate)(value, this.index++); diff --git a/src/operator/throttle.ts b/src/operator/throttle.ts index 345d6caf4c..af35cd18e2 100644 --- a/src/operator/throttle.ts +++ b/src/operator/throttle.ts @@ -29,7 +29,7 @@ class ThrottleSubscriber extends OuterSubscriber { super(destination); } - _next(value: T): void { + protected _next(value: T): void { if (!this.throttled) { const duration = tryCatch(this.durationSelector)(value); if (duration === errorObject) { diff --git a/src/operator/throttleTime.ts b/src/operator/throttleTime.ts index b3e1c4a29a..217743da4c 100644 --- a/src/operator/throttleTime.ts +++ b/src/operator/throttleTime.ts @@ -27,7 +27,7 @@ class ThrottleTimeSubscriber extends Subscriber { super(destination); } - _next(value: T) { + protected _next(value: T) { if (!this.throttled) { this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.delay, { subscriber: this })); this.destination.next(value); diff --git a/src/operator/timeInterval.ts b/src/operator/timeInterval.ts index 14e4f18505..a8de5032ab 100644 --- a/src/operator/timeInterval.ts +++ b/src/operator/timeInterval.ts @@ -33,7 +33,7 @@ class TimeIntervalSubscriber extends Subscriber { this.lastTime = scheduler.now(); } - _next(value: T) { + protected _next(value: T) { let now = this.scheduler.now(); let span = now - this.lastTime; this.lastTime = now; diff --git a/src/operator/timeout.ts b/src/operator/timeout.ts index 4401e67587..7738fe6a48 100644 --- a/src/operator/timeout.ts +++ b/src/operator/timeout.ts @@ -62,7 +62,7 @@ class TimeoutSubscriber extends Subscriber { this._previousIndex = currentIndex; } - _next(value: T) { + protected _next(value: T) { this.destination.next(value); if (!this.absoluteTimeout) { @@ -70,12 +70,12 @@ class TimeoutSubscriber extends Subscriber { } } - _error(err: any) { + protected _error(err: any) { this.destination.error(err); this._hasCompleted = true; } - _complete() { + protected _complete() { this.destination.complete(); this._hasCompleted = true; } diff --git a/src/operator/timeoutWith.ts b/src/operator/timeoutWith.ts index 23a25ff01c..0de6f48171 100644 --- a/src/operator/timeoutWith.ts +++ b/src/operator/timeoutWith.ts @@ -68,19 +68,19 @@ class TimeoutWithSubscriber extends OuterSubscriber { this._previousIndex = currentIndex; } - _next(value: T) { + protected _next(value: T) { this.destination.next(value); if (!this.absoluteTimeout) { this.scheduleTimeout(); } } - _error(err: any) { + protected _error(err: any) { this.destination.error(err); this._hasCompleted = true; } - _complete() { + protected _complete() { this.destination.complete(); this._hasCompleted = true; } diff --git a/src/operator/toArray.ts b/src/operator/toArray.ts index d2aec1b8b4..84a690e57c 100644 --- a/src/operator/toArray.ts +++ b/src/operator/toArray.ts @@ -20,11 +20,11 @@ class ToArraySubscriber extends Subscriber { super(destination); } - _next(x: T) { + protected _next(x: T) { this.array.push(x); } - _complete() { + protected _complete() { this.destination.next(this.array); this.destination.complete(); } diff --git a/src/operator/window.ts b/src/operator/window.ts index 7e239b590a..5d3024a847 100644 --- a/src/operator/window.ts +++ b/src/operator/window.ts @@ -27,16 +27,16 @@ class WindowSubscriber extends Subscriber { this.openWindow(); } - _next(value: T) { + protected _next(value: T) { this.window.next(value); } - _error(err: any) { + protected _error(err: any) { this.window.error(err); this.destination.error(err); } - _complete() { + protected _complete() { this.window.complete(); this.destination.complete(); } @@ -51,6 +51,14 @@ class WindowSubscriber extends Subscriber { destination.add(newWindow); destination.next(newWindow); } + + errorWindow(err: any) { + this._error(err); + } + + completeWindow() { + this._complete(); + } } class WindowClosingNotifierSubscriber extends Subscriber { @@ -58,15 +66,15 @@ class WindowClosingNotifierSubscriber extends Subscriber { super(); } - _next() { + protected _next() { this.parent.openWindow(); } - _error(err: any) { - this.parent._error(err); + protected _error(err: any) { + this.parent.errorWindow(err); } - _complete() { - this.parent._complete(); + protected _complete() { + this.parent.completeWindow(); } } diff --git a/src/operator/windowCount.ts b/src/operator/windowCount.ts index 8f732873e2..e40e2e882e 100644 --- a/src/operator/windowCount.ts +++ b/src/operator/windowCount.ts @@ -32,7 +32,7 @@ class WindowCountSubscriber extends Subscriber { destination.next(firstWindow); } - _next(value: T) { + protected _next(value: T) { const startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize; const destination = this.destination; const windowSize = this.windowSize; @@ -54,7 +54,7 @@ class WindowCountSubscriber extends Subscriber { } } - _error(err: any) { + protected _error(err: any) { const windows = this.windows; while (windows.length > 0) { windows.shift().error(err); @@ -62,7 +62,7 @@ class WindowCountSubscriber extends Subscriber { this.destination.error(err); } - _complete() { + protected _complete() { const windows = this.windows; while (windows.length > 0) { windows.shift().complete(); diff --git a/src/operator/windowTime.ts b/src/operator/windowTime.ts index 18f3555024..236c29c3bc 100644 --- a/src/operator/windowTime.ts +++ b/src/operator/windowTime.ts @@ -47,7 +47,7 @@ class WindowTimeSubscriber extends Subscriber { } } - _next(value: T) { + protected _next(value: T) { const windows = this.windows; const len = windows.length; for (let i = 0; i < len; i++) { @@ -55,7 +55,7 @@ class WindowTimeSubscriber extends Subscriber { } } - _error(err: any) { + protected _error(err: any) { const windows = this.windows; while (windows.length > 0) { windows.shift().error(err); @@ -63,7 +63,7 @@ class WindowTimeSubscriber extends Subscriber { this.destination.error(err); } - _complete() { + protected _complete() { const windows = this.windows; while (windows.length > 0) { windows.shift().complete(); diff --git a/src/operator/windowToggle.ts b/src/operator/windowToggle.ts index 01bc886f74..41b3852b16 100644 --- a/src/operator/windowToggle.ts +++ b/src/operator/windowToggle.ts @@ -44,7 +44,7 @@ class WindowToggleSubscriber extends OuterSubscriber { this.add(this.openSubscription = subscribeToResult(this, openings, openings)); } - _next(value: T) { + protected _next(value: T) { const { contexts } = this; if (contexts) { const len = contexts.length; @@ -54,7 +54,7 @@ class WindowToggleSubscriber extends OuterSubscriber { } } - _error(err: any) { + protected _error(err: any) { const { contexts } = this; this.contexts = null; @@ -73,7 +73,7 @@ class WindowToggleSubscriber extends OuterSubscriber { super._error(err); } - _complete() { + protected _complete() { const { contexts } = this; this.contexts = null; if (contexts) { diff --git a/src/operator/windowWhen.ts b/src/operator/windowWhen.ts index a170efcb32..39f97013b6 100644 --- a/src/operator/windowWhen.ts +++ b/src/operator/windowWhen.ts @@ -31,17 +31,17 @@ class WindowSubscriber extends Subscriber { this.openWindow(); } - _next(value: T) { + protected _next(value: T) { this.window.next(value); } - _error(err: any) { + protected _error(err: any) { this.window.error(err); this.destination.error(err); this._unsubscribeClosingNotification(); } - _complete() { + protected _complete() { this.window.complete(); this.destination.complete(); this._unsubscribeClosingNotification(); @@ -93,15 +93,15 @@ class WindowClosingNotifierSubscriber extends Subscriber { super(); } - _next() { + protected _next() { this.parent.openWindow(); } - _error(err: any) { + protected _error(err: any) { this.parent.error(err); } - _complete() { + protected _complete() { this.parent.openWindow(); } } diff --git a/src/operator/withLatestFrom.ts b/src/operator/withLatestFrom.ts index 1be3f92a98..196dcfd612 100644 --- a/src/operator/withLatestFrom.ts +++ b/src/operator/withLatestFrom.ts @@ -79,7 +79,7 @@ class WithLatestFromSubscriber extends OuterSubscriber { // noop } - _next(value: T) { + protected _next(value: T) { if (this.toRespond.length === 0) { const values = this.values; const destination = this.destination; diff --git a/src/operator/zip-support.ts b/src/operator/zip-support.ts index 146986f3d3..bdbbc99058 100644 --- a/src/operator/zip-support.ts +++ b/src/operator/zip-support.ts @@ -37,7 +37,7 @@ export class ZipSubscriber extends Subscriber { this.values = values; } - _next(value: any) { + protected _next(value: any) { const iterators = this.iterators; const index = this.index++; if (isArray(value)) { @@ -49,7 +49,7 @@ export class ZipSubscriber extends Subscriber { } } - _complete() { + protected _complete() { const iterators = this.iterators; const len = iterators.length; this.active = len;