import { Subscriber } from '../Subscriber';
import { Observable } from '../Observable';
import { Subscription } from '../Subscription';
-import { OuterSubscriber } from '../OuterSubscriber';
-import { InnerSubscriber } from '../InnerSubscriber';
-import { subscribeToResult } from '../util/subscribeToResult';
import { OperatorFunction } from '../types';
+import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
/**
* Buffers the source Observable values, using a factory function of closing
* @ignore
* @extends {Ignored}
*/
-class BufferWhenSubscriber<T> extends OuterSubscriber<T, any> {
- private buffer: T[];
+class BufferWhenSubscriber<T> extends SimpleOuterSubscriber<T, any> {
+ private buffer?: T[];
private subscribing: boolean = false;
- private closingSubscription: Subscription;
+ private closingSubscription?: Subscription;
constructor(destination: Subscriber<T[]>, private closingSelector: () => Observable<any>) {
super(destination);
}
protected _next(value: T) {
- this.buffer.push(value);
+ this.buffer!.push(value);
}
protected _complete() {
const buffer = this.buffer;
if (buffer) {
- this.destination.next(buffer);
+ this.destination.next!(buffer);
}
super._complete();
}
/** @deprecated This is an internal implementation detail, do not use. */
_unsubscribe() {
- this.buffer = null;
+ this.buffer = undefined;
this.subscribing = false;
}
- notifyNext(outerValue: T, innerValue: any,
- outerIndex: number, innerIndex: number,
- innerSub: InnerSubscriber<T, any>): void {
+ notifyNext(): void {
this.openBuffer();
}
const buffer = this.buffer;
if (this.buffer) {
- this.destination.next(buffer);
+ this.destination.next!(buffer);
}
this.buffer = [];
this.closingSubscription = closingSubscription;
this.add(closingSubscription);
this.subscribing = true;
- closingSubscription.add(subscribeToResult(this, closingNotifier));
+ closingSubscription.add(innerSubscribe(closingNotifier, new SimpleInnerSubscriber(this)));
this.subscribing = false;
}
}