From 97ce36c610d94b725bce94b0700f198e04fb4712 Mon Sep 17 00:00:00 2001 From: kwonoj Date: Thu, 17 Sep 2015 19:38:27 -0700 Subject: [PATCH] refactor(switch): rename switchAll to switch --- doc/index.md | 2 +- spec/operators/{switchAll-spec.js => switch-spec.js} | 8 ++++---- src/Observable.ts | 2 +- src/Rx.ts | 4 ++-- src/operators/{switchAll.ts => switch.ts} | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) rename spec/operators/{switchAll-spec.js => switch-spec.js} (88%) rename src/operators/{switchAll.ts => switch.ts} (96%) diff --git a/doc/index.md b/doc/index.md index 392bc27f4b..de06968712 100644 --- a/doc/index.md +++ b/doc/index.md @@ -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) diff --git a/spec/operators/switchAll-spec.js b/spec/operators/switch-spec.js similarity index 88% rename from spec/operators/switchAll-spec.js rename to spec/operators/switch-spec.js index 555749c287..2e9779384e 100644 --- a/spec/operators/switchAll-spec.js +++ b/spec/operators/switch-spec.js @@ -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); @@ -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); }); @@ -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); }); }); \ No newline at end of file diff --git a/src/Observable.ts b/src/Observable.ts index d104872aa4..469af56864 100644 --- a/src/Observable.ts +++ b/src/Observable.ts @@ -172,7 +172,7 @@ export default class Observable { expand: (project: (x: T, ix: number) => Observable) => Observable; delay: (delay: number, scheduler?: Scheduler) => Observable; - switchAll: () => Observable; + switch: () => Observable; switchLatest: (project: ((x: T, ix: number) => Observable), projectResult?: (x: T, y: any, ix: number, iy: number) => R) => Observable; switchLatestTo: (observable: Observable, diff --git a/src/Rx.ts b/src/Rx.ts index 864c6274dd..e118a8a2cf 100644 --- a/src/Rx.ts +++ b/src/Rx.ts @@ -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'; @@ -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; diff --git a/src/operators/switchAll.ts b/src/operators/switch.ts similarity index 96% rename from src/operators/switchAll.ts rename to src/operators/switch.ts index 9b84ad6598..4d4e5d5ef8 100644 --- a/src/operators/switchAll.ts +++ b/src/operators/switch.ts @@ -4,7 +4,7 @@ import Observable from '../Observable'; import Subscriber from '../Subscriber'; import Subscription from '../Subscription'; -export default function switchAll(): Observable { +export default function _switch(): Observable { return this.lift(new SwitchOperator()); }