Skip to content

Commit

Permalink
feat(reorganize): Move observable implementations under internal dire…
Browse files Browse the repository at this point in the history
…ctory

- Moves all files from `src/observables` to `src/internal/observables`
- Updates some tests to reference those internal files, this is
temprorary
- Adds an `index.ts` file at root that exports the static observable
creation functions

BREAKING CHANGE: You can no longer import observables from
`rxjs/observable/*`, now you must import them from `rxjs` directly, like
so: `import { fromEvent, timer } from 'rxjs';`

BREAKING CHANGE: You should no longer deep import custom Observable
implementations

BREAKING CHANGE: `_throw` is now exported as `throwError`

BREAKING CHANGE: `if` is now exported as `iif`
  • Loading branch information
benlesh committed Jan 12, 2018
1 parent 7342401 commit 2d5c3f8
Show file tree
Hide file tree
Showing 120 changed files with 364 additions and 403 deletions.
50 changes: 25 additions & 25 deletions spec/exports-spec.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { expect } from 'chai';
import { bindCallback } from '../src/observable/bindCallback';
import { bindNodeCallback } from '../src/observable/bindNodeCallback';
import { combineLatest } from '../src/observable/combineLatest';
import { concat } from '../src/observable/concat';
import { defer } from '../src/observable/defer';
import { empty } from '../src/observable/empty';
import { forkJoin } from '../src/observable/forkJoin';
import { from } from '../src/observable/from';
import { fromEvent } from '../src/observable/fromEvent';
import { fromEventPattern } from '../src/observable/fromEventPattern';
import { fromPromise } from '../src/observable/fromPromise';
import { _if } from '../src/observable/if';
import { interval } from '../src/observable/interval';
import { merge } from '../src/observable/merge';
import { never } from '../src/observable/never';
import { of } from '../src/observable/of';
import { onErrorResumeNext } from '../src/observable/onErrorResumeNext';
import { pairs } from '../src/observable/pairs';
import { race } from '../src/observable/race';
import { range } from '../src/observable/range';
import { _throw } from '../src/observable/throw';
import { timer } from '../src/observable/timer';
import { using } from '../src/observable/using';
import { zip } from '../src/observable/zip';
import { bindCallback } from '../src/internal/observable/bindCallback';
import { bindNodeCallback } from '../src/internal/observable/bindNodeCallback';
import { combineLatest } from '../src/internal/observable/combineLatest';
import { concat } from '../src/internal/observable/concat';
import { defer } from '../src/internal/observable/defer';
import { empty } from '../src/internal/observable/empty';
import { forkJoin } from '../src/internal/observable/forkJoin';
import { from } from '../src/internal/observable/from';
import { fromEvent } from '../src/internal/observable/fromEvent';
import { fromEventPattern } from '../src/internal/observable/fromEventPattern';
import { fromPromise } from '../src/internal/observable/fromPromise';
import { _if } from '../src/internal/observable/if';
import { interval } from '../src/internal/observable/interval';
import { merge } from '../src/internal/observable/merge';
import { never } from '../src/internal/observable/never';
import { of } from '../src/internal/observable/of';
import { onErrorResumeNext } from '../src/internal/observable/onErrorResumeNext';
import { pairs } from '../src/internal/observable/pairs';
import { race } from '../src/internal/observable/race';
import { range } from '../src/internal/observable/range';
import { _throw } from '../src/internal/observable/throw';
import { timer } from '../src/internal/observable/timer';
import { using } from '../src/internal/observable/using';
import { zip } from '../src/internal/observable/zip';
import * as Rx from '../src/Rx';

describe('exports', () => {
Expand Down Expand Up @@ -121,4 +121,4 @@ describe('exports', () => {
it('should have rxjs/observable/zip', () => {
expect(zip).to.equal(Rx.Observable.zip);
});
});
});
31 changes: 31 additions & 0 deletions spec/index-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as index from '../src/index';
import { expect } from 'chai';

describe('index', () => {
it('should export static observable creator functions', () => {
expect(index.bindCallback).to.exist;
expect(index.bindNodeCallback).to.exist;
expect(index.combineLatest).to.exist;
expect(index.concat).to.exist;
expect(index.defer).to.exist;
expect(index.empty).to.exist;
expect(index.forkJoin).to.exist;
expect(index.from).to.exist;
expect(index.fromEvent).to.exist;
expect(index.fromEventPattern).to.exist;
expect(index.generate).to.exist;
expect(index.iif).to.exist;
expect(index.interval).to.exist;
expect(index.merge).to.exist;
expect(index.never).to.exist;
expect(index.of).to.exist;
expect(index.onErrorResumeNext).to.exist;
expect(index.pairs).to.exist;
expect(index.race).to.exist;
expect(index.range).to.exist;
expect(index.throwError).to.exist;
expect(index.timer).to.exist;
expect(index.using).to.exist;
expect(index.zip).to.exist;
});
});
2 changes: 1 addition & 1 deletion spec/observables/IteratorObservable-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import * as Rx from '../../src/Rx';
import { queue } from '../../src/scheduler/queue';
import { IteratorObservable } from '../../src/observable/IteratorObservable';
import { IteratorObservable } from '../../src/internal/observable/IteratorObservable';

declare const expectObservable;
declare const rxTestScheduler: Rx.TestScheduler;
Expand Down
2 changes: 1 addition & 1 deletion spec/observables/ScalarObservable-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import * as Rx from '../../src/Rx';
import { ScalarObservable } from '../../src/observable/ScalarObservable';
import { ScalarObservable } from '../../src/internal/observable/ScalarObservable';

declare const rxTestScheduler: Rx.TestScheduler;

Expand Down
2 changes: 1 addition & 1 deletion spec/observables/SubscribeOnObservable-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import * as sinon from 'sinon';
import * as Rx from '../../src/Rx';
import { SubscribeOnObservable } from '../../src/observable/SubscribeOnObservable';
import { SubscribeOnObservable } from '../../src/internal/observable/SubscribeOnObservable';
import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports

declare const hot: typeof marbleTestingSignature.hot;
Expand Down
6 changes: 3 additions & 3 deletions spec/observables/of-spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import * as Rx from '../../src/Rx';
import { ArrayObservable } from '../../src/observable/ArrayObservable';
import { ScalarObservable } from '../../src/observable/ScalarObservable';
import { EmptyObservable } from '../../src/observable/EmptyObservable';
import { ArrayObservable } from '../../src/internal/observable/ArrayObservable';
import { ScalarObservable } from '../../src/internal/observable/ScalarObservable';
import { EmptyObservable } from '../../src/internal/observable/EmptyObservable';
import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports

declare const { asDiagram };
Expand Down
2 changes: 1 addition & 1 deletion spec/observables/range-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import * as sinon from 'sinon';
import * as Rx from '../../src/Rx';
import { RangeObservable } from '../../src/observable/RangeObservable';
import { RangeObservable } from '../../src/internal/observable/RangeObservable';
import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports

declare const { asDiagram };
Expand Down
2 changes: 1 addition & 1 deletion spec/observables/throw-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import * as Rx from '../../src/Rx';
import { ErrorObservable } from '../../src/observable/ErrorObservable';
import { ErrorObservable } from '../../src/internal/observable/ErrorObservable';
import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports

declare const { asDiagram };
Expand Down
2 changes: 1 addition & 1 deletion src/MiscJSDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { TeardownLogic } from './Subscription';
import { Observable } from './Observable';
import './observable/dom/MiscJSDoc';
import './internal/observable/dom/MiscJSDoc';
import { Observer } from './Observer';

/**
Expand Down
9 changes: 6 additions & 3 deletions src/Notification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { PartialObserver } from './Observer';
import { Observable } from './Observable';
import { empty } from './internal/observable/empty';
import { of } from './internal/observable/of';
import { _throw } from './internal/observable/throw';

/**
* Represents a push-based event or value that an {@link Observable} can emit.
Expand Down Expand Up @@ -84,11 +87,11 @@ export class Notification<T> {
const kind = this.kind;
switch (kind) {
case 'N':
return Observable.of(this.value);
return of(this.value);
case 'E':
return Observable.throw(this.error);
return _throw(this.error);
case 'C':
return Observable.empty<T>();
return empty<T>();
}
throw new Error('unexpected notification kind value');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Subscriber } from './Subscriber';
import { Subscription, AnonymousSubscription, TeardownLogic } from './Subscription';
import { root } from './util/root';
import { toSubscriber } from './util/toSubscriber';
import { IfObservable } from './observable/IfObservable';
import { ErrorObservable } from './observable/ErrorObservable';
import { IfObservable } from './internal/observable/IfObservable';
import { ErrorObservable } from './internal/observable/ErrorObservable';
import { observable as Symbol_observable } from './symbol/observable';
import { OperatorFunction } from './interfaces';
import { pipeFromArray } from './util/pipe';
Expand Down
4 changes: 2 additions & 2 deletions src/Rx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export {Subscriber} from './Subscriber';
export {AsyncSubject} from './AsyncSubject';
export {ReplaySubject} from './ReplaySubject';
export {BehaviorSubject} from './BehaviorSubject';
export {ConnectableObservable} from './observable/ConnectableObservable';
export {ConnectableObservable} from './internal/observable/ConnectableObservable';
export {Notification} from './Notification';
export {EmptyError} from './util/EmptyError';
export {ArgumentOutOfRangeError} from './util/ArgumentOutOfRangeError';
Expand All @@ -161,7 +161,7 @@ export {TimeInterval} from './internal/patching/operator/timeInterval';
export {Timestamp} from './operators/timestamp';
export {TestScheduler} from './testing/TestScheduler';
export {VirtualTimeScheduler} from './scheduler/VirtualTimeScheduler';
export {AjaxRequest, AjaxResponse, AjaxError, AjaxTimeoutError} from './observable/dom/AjaxObservable';
export {AjaxRequest, AjaxResponse, AjaxError, AjaxTimeoutError} from './internal/observable/dom/AjaxObservable';
export { pipe } from './util/pipe';

import { asap } from './scheduler/asap';
Expand Down
2 changes: 1 addition & 1 deletion src/add/observable/bindCallback.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Observable } from '../../Observable';
import { bindCallback as staticBindCallback } from '../../observable/bindCallback';
import { bindCallback as staticBindCallback } from '../../internal/observable/bindCallback';

Observable.bindCallback = staticBindCallback;

Expand Down
4 changes: 2 additions & 2 deletions src/add/observable/bindNodeCallback.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../Observable';
import { bindNodeCallback as staticBindNodeCallback } from '../../observable/bindNodeCallback';
import { bindNodeCallback as staticBindNodeCallback } from '../../internal/observable/bindNodeCallback';

Observable.bindNodeCallback = staticBindNodeCallback;

declare module '../../Observable' {
namespace Observable {
export let bindNodeCallback: typeof staticBindNodeCallback;
}
}
}
4 changes: 2 additions & 2 deletions src/add/observable/combineLatest.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../Observable';
import { combineLatest as combineLatestStatic } from '../../observable/combineLatest';
import { combineLatest as combineLatestStatic } from '../../internal/observable/combineLatest';

Observable.combineLatest = combineLatestStatic;

declare module '../../Observable' {
namespace Observable {
export let combineLatest: typeof combineLatestStatic;
}
}
}
4 changes: 2 additions & 2 deletions src/add/observable/concat.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../Observable';
import { concat as concatStatic } from '../../observable/concat';
import { concat as concatStatic } from '../../internal/observable/concat';

Observable.concat = concatStatic;

declare module '../../Observable' {
namespace Observable {
export let concat: typeof concatStatic;
}
}
}
4 changes: 2 additions & 2 deletions src/add/observable/defer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../Observable';
import { defer as staticDefer } from '../../observable/defer';
import { defer as staticDefer } from '../../internal/observable/defer';

Observable.defer = staticDefer;

declare module '../../Observable' {
namespace Observable {
export let defer: typeof staticDefer;
}
}
}
6 changes: 3 additions & 3 deletions src/add/observable/dom/ajax.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Observable } from '../../../Observable';
import { ajax as staticAjax } from '../../../observable/dom/ajax';
import { AjaxCreationMethod } from '../../../observable/dom/AjaxObservable';
import { ajax as staticAjax } from '../../../internal/observable/dom/ajax';
import { AjaxCreationMethod } from '../../../internal/observable/dom/AjaxObservable';

Observable.ajax = staticAjax;

declare module '../../../Observable' {
namespace Observable {
export let ajax: AjaxCreationMethod;
}
}
}
4 changes: 2 additions & 2 deletions src/add/observable/dom/webSocket.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../../Observable';
import { webSocket as staticWebSocket } from '../../../observable/dom/webSocket';
import { webSocket as staticWebSocket } from '../../../internal/observable/dom/webSocket';

Observable.webSocket = staticWebSocket;

declare module '../../../Observable' {
namespace Observable {
export let webSocket: typeof staticWebSocket;
}
}
}
4 changes: 2 additions & 2 deletions src/add/observable/empty.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../Observable';
import { empty as staticEmpty } from '../../observable/empty';
import { empty as staticEmpty } from '../../internal/observable/empty';

Observable.empty = staticEmpty;

declare module '../../Observable' {
namespace Observable {
export let empty: typeof staticEmpty;
}
}
}
4 changes: 2 additions & 2 deletions src/add/observable/forkJoin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../Observable';
import { forkJoin as staticForkJoin } from '../../observable/forkJoin';
import { forkJoin as staticForkJoin } from '../../internal/observable/forkJoin';

Observable.forkJoin = staticForkJoin;

declare module '../../Observable' {
namespace Observable {
export let forkJoin: typeof staticForkJoin;
}
}
}
4 changes: 2 additions & 2 deletions src/add/observable/from.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../Observable';
import { from as staticFrom } from '../../observable/from';
import { from as staticFrom } from '../../internal/observable/from';

Observable.from = staticFrom;

declare module '../../Observable' {
namespace Observable {
export let from: typeof staticFrom;
}
}
}
4 changes: 2 additions & 2 deletions src/add/observable/fromEvent.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../Observable';
import { fromEvent as staticFromEvent } from '../../observable/fromEvent';
import { fromEvent as staticFromEvent } from '../../internal/observable/fromEvent';

Observable.fromEvent = staticFromEvent;

declare module '../../Observable' {
namespace Observable {
export let fromEvent: typeof staticFromEvent;
}
}
}
4 changes: 2 additions & 2 deletions src/add/observable/fromEventPattern.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../Observable';
import { fromEventPattern as staticFromEventPattern } from '../../observable/fromEventPattern';
import { fromEventPattern as staticFromEventPattern } from '../../internal/observable/fromEventPattern';

Observable.fromEventPattern = staticFromEventPattern;

declare module '../../Observable' {
namespace Observable {
export let fromEventPattern: typeof staticFromEventPattern;
}
}
}
4 changes: 2 additions & 2 deletions src/add/observable/fromPromise.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../Observable';
import { fromPromise as staticFromPromise } from '../../observable/fromPromise';
import { fromPromise as staticFromPromise } from '../../internal/observable/fromPromise';

Observable.fromPromise = staticFromPromise;

declare module '../../Observable' {
namespace Observable {
export let fromPromise: typeof staticFromPromise;
}
}
}
4 changes: 2 additions & 2 deletions src/add/observable/generate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Observable } from '../../Observable';
import { generate as staticGenerate } from '../../observable/generate';
import { generate as staticGenerate } from '../../internal/observable/generate';

Observable.generate = staticGenerate;

declare module '../../Observable' {
namespace Observable {
export let generate: typeof staticGenerate;
}
}
}
Loading

0 comments on commit 2d5c3f8

Please sign in to comment.