From 43af805aee3d8c54824331943cc6c29573da63ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Gabriel=20Lima?= Date: Tue, 8 Dec 2015 11:39:04 -0300 Subject: [PATCH] feat(single): remove thisArg Relates to #878. --- src/CoreOperators.ts | 2 +- src/Observable.ts | 2 +- src/operator/single.ts | 17 ++++------------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/CoreOperators.ts b/src/CoreOperators.ts index bd24d5c175..433f5ad6fc 100644 --- a/src/CoreOperators.ts +++ b/src/CoreOperators.ts @@ -66,7 +66,7 @@ export interface CoreOperators { sampleTime?: (delay: number, scheduler?: Scheduler) => Observable; scan?: (project: (acc: R, x: T) => R, acc?: R) => Observable; share?: () => Observable; - single?: (predicate?: (value: T, index: number) => boolean, thisArg?: any) => Observable; + single?: (predicate?: (value: T, index: number) => boolean) => Observable; skip?: (count: number) => Observable; skipUntil?: (notifier: Observable) => Observable; skipWhile?: (predicate: (x: T, index: number) => boolean, thisArg?: any) => Observable; diff --git a/src/Observable.ts b/src/Observable.ts index bb065d6307..1dfb5d1c69 100644 --- a/src/Observable.ts +++ b/src/Observable.ts @@ -229,7 +229,7 @@ export class Observable implements CoreOperators { sampleTime: (delay: number, scheduler?: Scheduler) => Observable; scan: (accumulator: (acc: R, x: T) => R, seed?: T | R) => Observable; share: () => Observable; - single: (predicate?: (value: T, index: number) => boolean, thisArg?: any) => Observable; + single: (predicate?: (value: T, index: number) => boolean) => Observable; skip: (count: number) => Observable; skipUntil: (notifier: Observable) => Observable; skipWhile: (predicate: (x: T, index: number) => boolean, thisArg?: any) => Observable; diff --git a/src/operator/single.ts b/src/operator/single.ts index fceda4d191..d1299be1dd 100644 --- a/src/operator/single.ts +++ b/src/operator/single.ts @@ -5,42 +5,33 @@ import {Observer} from '../Observer'; import {tryCatch} from '../util/tryCatch'; import {errorObject} from '../util/errorObject'; -import {bindCallback} from '../util/bindCallback'; import {EmptyError} from '../util/EmptyError'; export function single(predicate?: (value: T, index: number, - source: Observable) => boolean, - thisArg?: any): Observable { - return this.lift(new SingleOperator(predicate, thisArg, this)); + source: Observable) => boolean): Observable { + return this.lift(new SingleOperator(predicate, this)); } class SingleOperator implements Operator { constructor(private predicate?: (value: T, index: number, source: Observable) => boolean, - private thisArg?: any, private source?: Observable) { } call(subscriber: Subscriber): Subscriber { - return new SingleSubscriber(subscriber, this.predicate, this.thisArg, this.source); + return new SingleSubscriber(subscriber, this.predicate, this.source); } } class SingleSubscriber extends Subscriber { - private predicate: Function; private seenValue: boolean = false; private singleValue: T; private index: number = 0; constructor(destination: Observer, - predicate?: (value: T, index: number, source: Observable) => boolean, - private thisArg?: any, + private predicate?: (value: T, index: number, source: Observable) => boolean, private source?: Observable) { super(destination); - - if (typeof predicate === 'function') { - this.predicate = bindCallback(predicate, thisArg, 3); - } } private applySingleValue(value): void {