Skip to content

Commit

Permalink
feat(finally): 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 132836f commit d4b02fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/CoreOperators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface CoreOperators<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>;
finally?: (ensure: () => void, thisArg?: any) => Observable<T>;
finally?: (finallySelector: () => void) => Observable<T>;
first?: <R>(predicate?: (value: T, index: number, source: Observable<T>) => boolean,
resultSelector?: (value: T, index: number) => R, thisArg?: any, defaultValue?: any) => Observable<T> | Observable<R>;
flatMap?: <R>(project: ((x: T, ix: number) => Observable<any>),
Expand Down
2 changes: 1 addition & 1 deletion src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class Observable<T> implements CoreOperators<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>;
finally: (ensure: () => void, thisArg?: any) => Observable<T>;
finally: (finallySelector: () => void) => Observable<T>;
first: <R>(predicate?: (value: T, index: number, source: Observable<T>) => boolean,
resultSelector?: (value: T, index: number) => R, thisArg?: any, defaultValue?: any) => Observable<T> | Observable<R>;
flatMap: <R>(project: ((x: T, ix: number) => Observable<any>),
Expand Down
15 changes: 4 additions & 11 deletions src/operator/finally.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import {Operator} from '../Operator';
import {Subscriber} from '../Subscriber';
import {Subscription} from '../Subscription';
import {bindCallback} from '../util/bindCallback';

export function _finally<T>(finallySelector: () => void, thisArg?: any) {
return this.lift(new FinallyOperator(thisArg ?
<() => void> bindCallback(finallySelector, thisArg, 2) :
finallySelector));
export function _finally<T>(finallySelector: () => void) {
return this.lift(new FinallyOperator(finallySelector));
}

class FinallyOperator<T, R> implements Operator<T, R> {

finallySelector: () => void;

constructor(finallySelector: () => void) {
this.finallySelector = finallySelector;
constructor(private finallySelector: () => void) {
}

call(subscriber: Subscriber<T>): Subscriber<T> {
Expand All @@ -27,4 +20,4 @@ class FinallySubscriber<T> extends Subscriber<T> {
super(destination);
this.add(new Subscription(finallySelector));
}
}
}

0 comments on commit d4b02fc

Please sign in to comment.