Skip to content

Commit

Permalink
refactor(skipWhile): remove thisArg argument
Browse files Browse the repository at this point in the history
- removes thisArg and tests around that from skipWhile
- removes extra thisArg on interface defs for first and last as well

BREAKING CHANGE: skipWhile no longer accepts a thisArg argument
related #878
  • Loading branch information
benlesh committed Dec 8, 2015
1 parent 43af805 commit d8f7297
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
17 changes: 0 additions & 17 deletions spec/operators/skipWhile-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,6 @@ describe('Observable.prototype.skipWhile()', function () {
expectSubscriptions(source.subscriptions).toBe(sourceSubs);
});

it('should accept a thisArg', function () {
var source = hot('-1-^--2--3--4--5--6--|');
var sourceSubs = '^ !';
var expected = '---------4--5--6--|';

function Skiper() {
this.doSkip = function (v) { return +v < 4; };
}

var skiper = new Skiper();

expectObservable(
source.skipWhile(function (v) { return this.doSkip(v); }, skiper)
).toBe(expected);
expectSubscriptions(source.subscriptions).toBe(sourceSubs);
});

it('should handle Observable.empty', function () {
var source = cold('|');
var subs = '(^!)';
Expand Down
6 changes: 3 additions & 3 deletions src/CoreOperators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface CoreOperators<T> {
filter?: (predicate: (x: T) => boolean, ix?: number, 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>;
resultSelector?: (value: T, index: number) => R, defaultValue?: any) => Observable<T> | Observable<R>;
flatMap?: <R>(project: ((x: T, ix: number) => Observable<any>),
projectResult?: (x: T, y: any, ix: number, iy: number) => R,
concurrent?: number) => Observable<R>;
Expand All @@ -41,7 +41,7 @@ export interface CoreOperators<T> {
ignoreElements?: () => Observable<T>;
last?: <R>(predicate?: (value: T, index: number) => boolean,
resultSelector?: (value: T, index: number) => R,
thisArg?: any, defaultValue?: any) => Observable<T> | Observable<R>;
defaultValue?: any) => Observable<T> | Observable<R>;
every?: (predicate: (value: T, index: number) => boolean, thisArg?: any) => Observable<T>;
map?: <R>(project: (x: T, ix?: number) => R, thisArg?: any) => Observable<R>;
mapTo?: <R>(value: R) => Observable<R>;
Expand Down Expand Up @@ -69,7 +69,7 @@ export interface CoreOperators<T> {
single?: (predicate?: (value: T, index: number) => boolean) => Observable<T>;
skip?: (count: number) => Observable<T>;
skipUntil?: (notifier: Observable<any>) => Observable<T>;
skipWhile?: (predicate: (x: T, index: number) => boolean, thisArg?: any) => Observable<T>;
skipWhile?: (predicate: (x: T, index: number) => boolean) => Observable<T>;
startWith?: (x: T) => Observable<T>;
subscribeOn?: (scheduler: Scheduler, delay?: number) => Observable<T>;
switch?: () => Observable<T>;
Expand Down
10 changes: 3 additions & 7 deletions src/operator/skipWhile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,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 skipWhile<T>(predicate: (x: T, index: number) => boolean, thisArg?: any): Observable<T> {
return this.lift(new SkipWhileOperator(predicate, thisArg));
export function skipWhile<T>(predicate: (x: T, index: number) => boolean): Observable<T> {
return this.lift(new SkipWhileOperator(predicate));
}

class SkipWhileOperator<T, R> implements Operator<T, R> {
private predicate: (x: T, index: number) => boolean;

constructor(predicate: (x: T, index: number) => boolean, thisArg?: any) {
this.predicate = <(x: T, index: number) => boolean>bindCallback(predicate, thisArg, 2);
constructor(private predicate: (x: T, index: number) => boolean) {
}

call(subscriber: Subscriber<T>): Subscriber<T> {
Expand Down

0 comments on commit d8f7297

Please sign in to comment.