Skip to content

Commit

Permalink
refactor(switch): rename switchAll to switch
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Sep 18, 2015
1 parent e7eb5d7 commit 97ce36c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
- [skipUntil](function/index.html#static-function-skipUntil)
- [startWith](function/index.html#static-function-startWith)
- [subscribeOn](function/index.html#static-function-subscribeOn)
- [switchAll](function/index.html#static-function-switchAll)
- [switch](function/index.html#static-function-switch)
- [switchLatest](function/index.html#static-function-switchLatest)
- [switchLatestTo](function/index.html#static-function-switchLatestTo)
- [take](function/index.html#static-function-take)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ var Rx = require('../../dist/cjs/Rx');
var Observable = Rx.Observable;
var immediateScheduler = Rx.Scheduler.immediate;

describe('Observable.prototype.switchAll()', function(){
describe('Observable.prototype.switch()', function(){
it("should switch to each immediately-scheduled inner Observable", function (done) {
var a = Observable.of(1, 2, 3, immediateScheduler);
var b = Observable.of(4, 5, 6, immediateScheduler);
var r = [1, 4, 5, 6];
var i = 0;
Observable.of(a, b, immediateScheduler)
.switchAll()
.switch()
.subscribe(function (x) {
expect(x).toBe(r[i++]);
}, null, done);
Expand Down Expand Up @@ -39,7 +39,7 @@ describe('Observable.prototype.switchAll()', function(){
var b = Observable.of(4, 5, 6);
var r = [1, 2, 3, 4, 5, 6];
var i = 0;
Observable.of(a, b).switchAll().subscribe(function (x) {
Observable.of(a, b).switch().subscribe(function (x) {
expect(x).toBe(r[i++]);
}, null, done);
});
Expand All @@ -49,6 +49,6 @@ describe('Observable.prototype.switchAll()', function(){
var y = cold( '---d--e---f---|');
var e1 = hot( '------x-------y------|', { x: x, y: y });
var expected = '--------a---b----d--e---f---|';
expectObservable(e1.switchAll()).toBe(expected);
expectObservable(e1.switch()).toBe(expected);
});
});
2 changes: 1 addition & 1 deletion src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default class Observable<T> {
expand: (project: (x: T, ix: number) => Observable<any>) => Observable<any>;
delay: <T>(delay: number, scheduler?: Scheduler) => Observable<T>;

switchAll: <R>() => Observable<R>;
switch: <R>() => Observable<R>;
switchLatest: <R>(project: ((x: T, ix: number) => Observable<any>),
projectResult?: (x: T, y: any, ix: number, iy: number) => R) => Observable<R>;
switchLatestTo: <R>(observable: Observable<any>,
Expand Down
4 changes: 2 additions & 2 deletions src/Rx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import merge from './operators/merge-static';
import mergeAll from './operators/mergeAll';
import flatMap from './operators/flatMap';
import flatMapTo from './operators/flatMapTo';
import switchAll from './operators/switchAll';
import _switch from './operators/switch';
import switchLatest from './operators/switchLatest';
import switchLatestTo from './operators/switchLatestTo';
import expand from './operators/expand';
Expand All @@ -76,7 +76,7 @@ observableProto.merge = mergeProto;
observableProto.mergeAll = mergeAll;
observableProto.flatMap = flatMap;
observableProto.flatMapTo = flatMapTo;
observableProto.switchAll = switchAll;
observableProto.switch = _switch;
observableProto.switchLatest = switchLatest;
observableProto.switchLatestTo = switchLatestTo;
observableProto.expand = expand;
Expand Down
2 changes: 1 addition & 1 deletion src/operators/switchAll.ts → src/operators/switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Observable from '../Observable';
import Subscriber from '../Subscriber';
import Subscription from '../Subscription';

export default function switchAll<T>(): Observable<T> {
export default function _switch<T>(): Observable<T> {
return this.lift(new SwitchOperator());
}

Expand Down

0 comments on commit 97ce36c

Please sign in to comment.