Skip to content

Commit

Permalink
feat(distinctUntilChanged): remove thisArg
Browse files Browse the repository at this point in the history
relates to #878
  • Loading branch information
kwonoj committed Dec 8, 2015
1 parent b6573fb commit bfc52d6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/CoreOperators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface CoreOperators<T> {
debounceTime?: <R>(dueTime: number, scheduler?: Scheduler) => Observable<R>;
defaultIfEmpty?: <R>(defaultValue?: T | R) => Observable<T> | Observable<R>;
delay?: (delay: number, scheduler?: Scheduler) => Observable<T>;
distinctUntilChanged?: (compare?: (x: T, y: T) => boolean, thisArg?: any) => Observable<T>;
distinctUntilChanged?: (compare?: (x: T, y: T) => boolean) => Observable<T>;
do?: (next?: (x: T) => void, error?: (e: any) => void, complete?: () => void) => Observable<T>;
expand?: <R>(project: (x: T, ix: number) => Observable<R>, concurrent: number, scheduler: Scheduler) => Observable<R>;
filter?: (predicate: (x: T) => boolean, ix?: number, thisArg?: any) => Observable<T>;
Expand Down
2 changes: 1 addition & 1 deletion src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class Observable<T> implements CoreOperators<T> {
debounceTime: <R>(dueTime: number, scheduler?: Scheduler) => Observable<R>;
defaultIfEmpty: <R>(defaultValue?: T | R) => Observable<T> | Observable<R>;
delay: (delay: number, scheduler?: Scheduler) => Observable<T>;
distinctUntilChanged: (compare?: (x: T, y: T) => boolean, thisArg?: any) => Observable<T>;
distinctUntilChanged: (compare?: (x: T, y: T) => boolean) => Observable<T>;
do: (next?: (x: T) => void, error?: (e: any) => void, complete?: () => void) => Observable<T>;
expand: <R>(project: (x: T, ix: number) => Observable<R>, concurrent: number, scheduler: Scheduler) => Observable<R>;
filter: (predicate: (x: T) => boolean, ix?: number, thisArg?: any) => Observable<T>;
Expand Down
11 changes: 4 additions & 7 deletions src/operator/distinctUntilChanged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import {Operator} from '../Operator';
import {Subscriber} from '../Subscriber';
import {tryCatch} from '../util/tryCatch';
import {errorObject} from '../util/errorObject';
import {bindCallback} from '../util/bindCallback';

export function distinctUntilChanged<T>(compare?: (x: T, y: T) => boolean, thisArg?: any) {
return this.lift(new DistinctUntilChangedOperator(thisArg ?
<(x: T, y: T) => boolean> bindCallback(compare, thisArg, 2) :
compare));
export function distinctUntilChanged<T>(compare?: (x: T, y: T) => boolean) {
return this.lift(new DistinctUntilChangedOperator(compare));
}

class DistinctUntilChangedOperator<T, R> implements Operator<T, R> {
constructor(private compare?: (x: T, y: T) => boolean) {
constructor(private compare: (x: T, y: T) => boolean) {
}

call(subscriber: Subscriber<T>): Subscriber<T> {
Expand All @@ -23,7 +20,7 @@ class DistinctUntilChangedSubscriber<T> extends Subscriber<T> {
private value: T;
private hasValue: boolean = false;

constructor(destination: Subscriber<T>, compare?: (x: T, y: T) => boolean) {
constructor(destination: Subscriber<T>, compare: (x: T, y: T) => boolean) {
super(destination);
if (typeof compare === 'function') {
this.compare = compare;
Expand Down

0 comments on commit bfc52d6

Please sign in to comment.