Skip to content

Commit eddd4dc

Browse files
committed
feat(switchFirstMap): rename switchMapFirst to switchFirstMap
related #915
1 parent c9da8cb commit eddd4dc

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

spec/operators/switchMapFirst-spec.js renamed to spec/operators/switchFirstMap-spec.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ var Promise = require('promise');
55
var Observable = Rx.Observable;
66
var queueScheduler = Rx.Scheduler.queue;
77

8-
describe('Observable.prototype.switchMapFirst()', function () {
8+
describe('Observable.prototype.switchFirstMap()', function () {
99
it('should handle outer throw', function () {
1010
var x = cold('--a--b--c--|');
1111
var xsubs = [];
1212
var e1 = cold('#');
1313
var e1subs = '(^!)';
1414
var expected = '#';
1515

16-
var result = e1.switchMapFirst(function () { return x; });
16+
var result = e1.switchFirstMap(function () { return x; });
1717

1818
expectObservable(result).toBe(expected);
1919
expectSubscriptions(x.subscriptions).toBe(xsubs);
@@ -27,7 +27,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
2727
var e1subs = '(^!)';
2828
var expected = '|';
2929

30-
var result = e1.switchMapFirst(function () { return x; });
30+
var result = e1.switchFirstMap(function () { return x; });
3131
expectObservable(result).toBe(expected);
3232
expectSubscriptions(x.subscriptions).toBe(xsubs);
3333
expectSubscriptions(e1.subscriptions).toBe(e1subs);
@@ -40,7 +40,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
4040
var e1subs = '^';
4141
var expected = '-';
4242

43-
var result = e1.switchMapFirst(function () { return x; });
43+
var result = e1.switchFirstMap(function () { return x; });
4444

4545
expectObservable(result).toBe(expected);
4646
expectSubscriptions(x.subscriptions).toBe(xsubs);
@@ -52,7 +52,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
5252
var e1subs = '^ !';
5353
var expected = '---#';
5454

55-
var result = e1.switchMapFirst(function (value) {
55+
var result = e1.switchFirstMap(function (value) {
5656
throw 'error';
5757
});
5858

@@ -67,7 +67,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
6767
var e1subs = '^ ! ';
6868
var expected = '-----# ';
6969

70-
var result = e1.switchMapFirst(function (value) {
70+
var result = e1.switchFirstMap(function (value) {
7171
return x;
7272
}, function () {
7373
throw 'error';
@@ -91,7 +91,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
9191

9292
var observableLookup = { x: x, y: y, z: z };
9393

94-
var result = e1.switchMapFirst(function (value) {
94+
var result = e1.switchFirstMap(function (value) {
9595
return observableLookup[value];
9696
});
9797

@@ -116,7 +116,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
116116

117117
var observableLookup = { x: x, y: y, z: z };
118118

119-
var result = e1.switchMapFirst(function (value) {
119+
var result = e1.switchFirstMap(function (value) {
120120
return observableLookup[value];
121121
});
122122

@@ -140,7 +140,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
140140

141141
var observableLookup = { x: x, y: y, z: z };
142142

143-
var result = e1.switchMapFirst(function (value) {
143+
var result = e1.switchFirstMap(function (value) {
144144
return observableLookup[value];
145145
});
146146

@@ -162,7 +162,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
162162

163163
var observableLookup = { x: x, y: y };
164164

165-
var result = e1.switchMapFirst(function (value) {
165+
var result = e1.switchFirstMap(function (value) {
166166
return observableLookup[value];
167167
});
168168

@@ -183,7 +183,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
183183

184184
var observableLookup = { x: x, y: y };
185185

186-
var result = e1.switchMapFirst(function (value) {
186+
var result = e1.switchFirstMap(function (value) {
187187
return observableLookup[value];
188188
});
189189

@@ -206,7 +206,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
206206

207207
var observableLookup = { x: x, y: y, z: z };
208208

209-
var result = e1.switchMapFirst(function (value) {
209+
var result = e1.switchFirstMap(function (value) {
210210
return observableLookup[value];
211211
});
212212

@@ -228,7 +228,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
228228

229229
var observableLookup = { x: x, y: y };
230230

231-
var result = e1.switchMapFirst(function (value) {
231+
var result = e1.switchFirstMap(function (value) {
232232
return observableLookup[value];
233233
});
234234

@@ -249,7 +249,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
249249

250250
var observableLookup = { x: x, y: y };
251251

252-
var result = e1.switchMapFirst(function (value) {
252+
var result = e1.switchFirstMap(function (value) {
253253
return observableLookup[value];
254254
});
255255

@@ -270,7 +270,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
270270

271271
var observableLookup = { x: x, y: y };
272272

273-
var result = e1.switchMapFirst(function (value) {
273+
var result = e1.switchFirstMap(function (value) {
274274
return observableLookup[value];
275275
});
276276

@@ -291,7 +291,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
291291

292292
var observableLookup = { x: x, y: y };
293293

294-
var result = e1.switchMapFirst(function (value) {
294+
var result = e1.switchFirstMap(function (value) {
295295
return observableLookup[value];
296296
});
297297

@@ -310,7 +310,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
310310

311311
var observableLookup = { x: x };
312312

313-
var result = e1.switchMapFirst(function (value) {
313+
var result = e1.switchFirstMap(function (value) {
314314
return observableLookup[value];
315315
});
316316

@@ -344,7 +344,7 @@ describe('Observable.prototype.switchMapFirst()', function () {
344344
n: ['z', 'n', 1, 3],
345345
};
346346

347-
var result = e1.switchMapFirst(function (value) {
347+
var result = e1.switchFirstMap(function (value) {
348348
return observableLookup[value];
349349
}, function (innerValue, outerValue, innerIndex, outerIndex) {
350350
return [innerValue, outerValue, innerIndex, outerIndex];

src/Observable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export class Observable<T> implements CoreOperators<T> {
238238
switch: <R>() => Observable<R>;
239239
switchFirst: <T>() => Observable<T>;
240240
switchMap: <R>(project: ((x: T, ix: number) => Observable<any>), projectResult?: (x: T, y: any, ix: number, iy: number) => R) => Observable<R>;
241-
switchMapFirst: <T, R, R2>(project: (x: T, ix: number) => Observable<R>, rSelector?: (x: T, y: R, ix: number, iy: number) => R2) => Observable<R>;
241+
switchFirstMap: <T, R, R2>(project: (x: T, ix: number) => Observable<R>, rSelector?: (x: T, y: R, ix: number, iy: number) => R2) => Observable<R>;
242242
switchMapTo: <R>(observable: Observable<any>, projectResult?: (x: T, y: any, ix: number, iy: number) => R) => Observable<R>;
243243
take: (count: number) => Observable<T>;
244244
takeUntil: (notifier: Observable<any>) => Observable<T>;

src/Rx.KitchenSink.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface KitchenSinkOperators<T> extends CoreOperators<T> {
1616
timeInterval?: <T>(scheduler?: IScheduler) => Observable<T>;
1717
mergeScan?: <T, R>(project: (acc: R, x: T) => Observable<R>, seed: R, concurrent?: number) => Observable<R>;
1818
switchFirst?: () => Observable<T>;
19-
switchMapFirst?: <R>(project: ((x: T, ix: number) => Observable<any>),
19+
switchFirstMap?: <R>(project: ((x: T, ix: number) => Observable<any>),
2020
projectResult?: (x: T, y: any, ix: number, iy: number) => R) => Observable<R>;
2121
}
2222

src/Rx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ import './add/operator/subscribeOn';
8787
import './add/operator/switch';
8888
import './add/operator/switchFirst';
8989
import './add/operator/switchMap';
90-
import './add/operator/switchMapFirst';
90+
import './add/operator/switchFirstMap';
9191
import './add/operator/switchMapTo';
9292
import './add/operator/take';
9393
import './add/operator/takeUntil';

src/add/operator/switchFirstMap.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import {Observable} from '../../Observable';
2+
import {switchFirstMap} from '../../operator/switchFirstMap';
3+
Observable.prototype.switchFirstMap = switchFirstMap;

src/add/operator/switchMapFirst.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/operator/switchMapFirst.ts renamed to src/operator/switchFirstMap.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import {errorObject} from '../util/errorObject';
66
import {OuterSubscriber} from '../OuterSubscriber';
77
import {subscribeToResult} from '../util/subscribeToResult';
88

9-
export function switchMapFirst<T, R, R2>(project: (value: T, index: number) => Observable<R>,
9+
export function switchFirstMap<T, R, R2>(project: (value: T, index: number) => Observable<R>,
1010
resultSelector?: (outerValue: T,
1111
innerValue: R,
1212
outerIndex: number,
1313
innerIndex: number) => R2): Observable<R> {
14-
return this.lift(new SwitchMapFirstOperator(project, resultSelector));
14+
return this.lift(new SwitchFirstMapOperator(project, resultSelector));
1515
}
1616

17-
class SwitchMapFirstOperator<T, R, R2> implements Operator<T, R> {
17+
class SwitchFirstMapOperator<T, R, R2> implements Operator<T, R> {
1818
constructor(private project: (value: T, index: number) => Observable<R>,
1919
private resultSelector?: (outerValue: T,
2020
innerValue: R,
@@ -23,11 +23,11 @@ class SwitchMapFirstOperator<T, R, R2> implements Operator<T, R> {
2323
}
2424

2525
call(subscriber: Subscriber<R>): Subscriber<T> {
26-
return new SwitchMapFirstSubscriber(subscriber, this.project, this.resultSelector);
26+
return new SwitchFirstMapSubscriber(subscriber, this.project, this.resultSelector);
2727
}
2828
}
2929

30-
class SwitchMapFirstSubscriber<T, R, R2> extends OuterSubscriber<T, R> {
30+
class SwitchFirstMapSubscriber<T, R, R2> extends OuterSubscriber<T, R> {
3131
private hasSubscription: boolean = false;
3232
private hasCompleted: boolean = false;
3333
private index: number = 0;

0 commit comments

Comments
 (0)