Skip to content

Commit

Permalink
refactor(patches): move static observable stubs from Observable.ts to…
Browse files Browse the repository at this point in the history
… patch files
  • Loading branch information
david-driscoll committed Feb 25, 2016
1 parent d99289f commit a979cdf
Show file tree
Hide file tree
Showing 25 changed files with 164 additions and 74 deletions.
45 changes: 1 addition & 44 deletions src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,7 @@ import {toSubscriber} from './util/toSubscriber';
import {tryCatch} from './util/tryCatch';
import {errorObject} from './util/errorObject';

import {combineLatestStatic} from './operator/combineLatest';
import {concatStatic} from './operator/concat';
import {mergeStatic} from './operator/merge';
import {zipStatic} from './operator/zip';
import {BoundCallbackObservable} from './observable/BoundCallbackObservable';
import {BoundNodeCallbackObservable} from './observable/BoundNodeCallbackObservable';
import {DeferObservable} from './observable/DeferObservable';
import {EmptyObservable} from './observable/EmptyObservable';
import {ForkJoinObservable} from './observable/ForkJoinObservable';
import {FromObservable} from './observable/FromObservable';
import {ArrayObservable} from './observable/ArrayObservable';
import {FromEventObservable} from './observable/FromEventObservable';
import {FromEventPatternObservable} from './observable/FromEventPatternObservable';
import {PromiseObservable} from './observable/PromiseObservable';
import {IntervalObservable} from './observable/IntervalObservable';
import {TimerObservable} from './observable/TimerObservable';
import {raceStatic} from './operator/race';
import {RangeObservable} from './observable/RangeObservable';
import {NeverObservable} from './observable/NeverObservable';
import {ErrorObservable} from './observable/ErrorObservable';
import {AjaxCreationMethod} from './observable/dom/AjaxObservable';
import {WebSocketSubject} from './observable/dom/WebSocketSubject';

export type ObservableOrPromise<T> = Observable<T> | Promise<T>;
export type ArrayOrIterator<T> = Iterator<T> | ArrayLike<T>;
Expand Down Expand Up @@ -159,30 +138,8 @@ export class Observable<T> {
return this.source.subscribe(subscriber);
}

// static method stubs
static ajax: AjaxCreationMethod;
static bindCallback: typeof BoundCallbackObservable.create;
static bindNodeCallback: typeof BoundNodeCallbackObservable.create;
static combineLatest: typeof combineLatestStatic;
static concat: typeof concatStatic;
static defer: typeof DeferObservable.create;
static empty: typeof EmptyObservable.create;
static forkJoin: typeof ForkJoinObservable.create;
static from: typeof FromObservable.create;
static fromArray: typeof ArrayObservable.create;
static fromEvent: typeof FromEventObservable.create;
static fromEventPattern: typeof FromEventPatternObservable.create;
static fromPromise: typeof PromiseObservable.create;
static interval: typeof IntervalObservable.create;
static merge: typeof mergeStatic;
static never: typeof NeverObservable.create;
static of: typeof ArrayObservable.of;
static race: typeof raceStatic;
static range: typeof RangeObservable.create;
// Throw is the special snow flake, the compiler sees it as a reserved word
static throw: typeof ErrorObservable.create;
static timer: typeof TimerObservable.create;
static webSocket: typeof WebSocketSubject.create;
static zip: typeof zipStatic;

/**
* @method Symbol.observable
Expand Down
4 changes: 4 additions & 0 deletions src/Rx.KitchenSink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ import './add/operator/mergeScan';
import './add/operator/min';
import './add/operator/pairwise';
import './add/operator/timeInterval';

export {TimeInterval} from './operator/timeInterval';
export {TestScheduler} from './testing/TestScheduler';
export {VirtualTimeScheduler} from './scheduler/VirtualTimeScheduler';
9 changes: 5 additions & 4 deletions src/Rx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ export {Observable} from './Observable';

// statics
/* tslint:disable:no-use-before-declare */
import './add/observable/combineLatest';
import './add/observable/concat';
import './add/observable/merge';
import './add/observable/race';
import './add/observable/bindCallback';
import './add/observable/bindNodeCallback';
import './add/observable/combineLatest';
import './add/observable/concat';
import './add/observable/defer';
import './add/observable/empty';
import './add/observable/forkJoin';
Expand All @@ -23,7 +21,10 @@ import './add/observable/fromEvent';
import './add/observable/fromEventPattern';
import './add/observable/fromPromise';
import './add/observable/interval';
import './add/observable/merge';
import './add/observable/race';
import './add/observable/never';
import './add/observable/of';
import './add/observable/range';
import './add/observable/throw';
import './add/observable/timer';
Expand Down
8 changes: 7 additions & 1 deletion src/add/observable/bindCallback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {BoundCallbackObservable} from '../../observable/BoundCallbackObservable';

Observable.bindCallback = BoundCallbackObservable.create;
Observable.bindCallback = BoundCallbackObservable.create;

declare module '../../Observable' {
namespace Observable {
export let bindCallback: typeof BoundCallbackObservable.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/bindNodeCallback.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {BoundNodeCallbackObservable} from '../../observable/BoundNodeCallbackObservable';

Observable.bindNodeCallback = BoundNodeCallbackObservable.create;
Observable.bindNodeCallback = BoundNodeCallbackObservable.create;

declare module '../../Observable' {
namespace Observable {
export let bindNodeCallback: typeof BoundNodeCallbackObservable.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/combineLatest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {combineLatestStatic} from '../../operator/combineLatest';

Observable.combineLatest = combineLatestStatic;
Observable.combineLatest = combineLatestStatic;

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

import {Observable} from '../../Observable';
import {concatStatic} from '../../operator/concat';

Observable.concat = concatStatic;
Observable.concat = concatStatic;

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

Observable.defer = DeferObservable.create;
Observable.defer = DeferObservable.create;

declare module '../../Observable' {
namespace Observable {
export let defer: typeof DeferObservable.create;
}
}
9 changes: 7 additions & 2 deletions src/add/observable/dom/ajax.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

import {Observable} from '../../../Observable';
import {AjaxObservable} from '../../../observable/dom/AjaxObservable';

Observable.ajax = AjaxObservable.create;
Observable.ajax = AjaxObservable.create;

declare module '../../../Observable' {
namespace Observable {
export let ajax: typeof AjaxObservable.create;
}
}
9 changes: 7 additions & 2 deletions src/add/observable/dom/webSocket.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

import {Observable} from '../../../Observable';
import {WebSocketSubject} from '../../../observable/dom/WebSocketSubject';

Observable.webSocket = WebSocketSubject.create;
Observable.webSocket = WebSocketSubject.create;

declare module '../../../Observable' {
namespace Observable {
export let webSocket: typeof WebSocketSubject.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/empty.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {EmptyObservable} from '../../observable/EmptyObservable';

Observable.empty = EmptyObservable.create;
Observable.empty = EmptyObservable.create;

declare module '../../Observable' {
namespace Observable {
export let empty: typeof EmptyObservable.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/forkJoin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {ForkJoinObservable} from '../../observable/ForkJoinObservable';

Observable.forkJoin = ForkJoinObservable.create;
Observable.forkJoin = ForkJoinObservable.create;

declare module '../../Observable' {
namespace Observable {
export let forkJoin: typeof ForkJoinObservable.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/from.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {FromObservable} from '../../observable/FromObservable';

Observable.from = FromObservable.create;
Observable.from = FromObservable.create;

declare module '../../Observable' {
namespace Observable {
export let from: typeof FromObservable.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/fromArray.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import {Observable} from '../../Observable';
import {ArrayObservable} from '../../observable/ArrayObservable';
import './of';

Observable.fromArray = ArrayObservable.create;
Observable.of = ArrayObservable.of;

declare module '../../Observable' {
namespace Observable {
export let fromArray: typeof ArrayObservable.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/fromEvent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {FromEventObservable} from '../../observable/FromEventObservable';

Observable.fromEvent = FromEventObservable.create;
Observable.fromEvent = FromEventObservable.create;

declare module '../../Observable' {
namespace Observable {
export let fromEvent: typeof FromEventObservable.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/fromEventPattern.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {FromEventPatternObservable} from '../../observable/FromEventPatternObservable';

Observable.fromEventPattern = FromEventPatternObservable.create;
Observable.fromEventPattern = FromEventPatternObservable.create;

declare module '../../Observable' {
namespace Observable {
export let fromEventPattern: typeof FromEventPatternObservable.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/fromPromise.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {PromiseObservable} from '../../observable/PromiseObservable';

Observable.fromPromise = PromiseObservable.create;
Observable.fromPromise = PromiseObservable.create;

declare module '../../Observable' {
namespace Observable {
export let fromPromise: typeof PromiseObservable.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/interval.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {IntervalObservable} from '../../observable/IntervalObservable';

Observable.interval = IntervalObservable.create;
Observable.interval = IntervalObservable.create;

declare module '../../Observable' {
namespace Observable {
export let interval: typeof IntervalObservable.create;
}
}
9 changes: 7 additions & 2 deletions src/add/observable/merge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

import {Observable} from '../../Observable';
import {mergeStatic} from '../../operator/merge';

Observable.merge = mergeStatic;
Observable.merge = mergeStatic;

declare module '../../Observable' {
namespace Observable {
export let merge: typeof mergeStatic;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/never.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {NeverObservable} from '../../observable/NeverObservable';

Observable.never = NeverObservable.create;
Observable.never = NeverObservable.create;

declare module '../../Observable' {
namespace Observable {
export let never: typeof NeverObservable.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/of.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {ArrayObservable} from '../../observable/ArrayObservable';

Observable.of = ArrayObservable.of;
Observable.of = ArrayObservable.of;

declare module '../../Observable' {
namespace Observable {
export let of: typeof ArrayObservable.of;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/race.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {raceStatic} from '../../operator/race';

Observable.race = raceStatic;
Observable.race = raceStatic;

declare module '../../Observable' {
namespace Observable {
export let race: typeof raceStatic;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/range.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {RangeObservable} from '../../observable/RangeObservable';

Observable.range = RangeObservable.create;
Observable.range = RangeObservable.create;

declare module '../../Observable' {
namespace Observable {
export let range: typeof RangeObservable.create;
}
}
8 changes: 7 additions & 1 deletion src/add/observable/timer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import {Observable} from '../../Observable';
import {TimerObservable} from '../../observable/TimerObservable';

Observable.timer = TimerObservable.create;
Observable.timer = TimerObservable.create;

declare module '../../Observable' {
namespace Observable {
export let timer: typeof TimerObservable.create;
}
}
Loading

0 comments on commit a979cdf

Please sign in to comment.