diff --git a/src/Observable.ts b/src/Observable.ts index 5a60d5852e..be5516a758 100644 --- a/src/Observable.ts +++ b/src/Observable.ts @@ -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 = Observable | Promise; export type ArrayOrIterator = Iterator | ArrayLike; @@ -159,30 +138,8 @@ export class Observable { 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 diff --git a/src/Rx.ts b/src/Rx.ts index 6e2cb9f9fb..ae421a5f36 100644 --- a/src/Rx.ts +++ b/src/Rx.ts @@ -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'; @@ -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'; diff --git a/src/add/observable/bindCallback.ts b/src/add/observable/bindCallback.ts index fe605032c1..5b2d581a28 100644 --- a/src/add/observable/bindCallback.ts +++ b/src/add/observable/bindCallback.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {BoundCallbackObservable} from '../../observable/BoundCallbackObservable'; -Observable.bindCallback = BoundCallbackObservable.create; \ No newline at end of file +Observable.bindCallback = BoundCallbackObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let bindCallback: typeof BoundCallbackObservable.create; + } +} diff --git a/src/add/observable/bindNodeCallback.ts b/src/add/observable/bindNodeCallback.ts index 665b03ebf8..37697f293a 100644 --- a/src/add/observable/bindNodeCallback.ts +++ b/src/add/observable/bindNodeCallback.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {BoundNodeCallbackObservable} from '../../observable/BoundNodeCallbackObservable'; -Observable.bindNodeCallback = BoundNodeCallbackObservable.create; \ No newline at end of file +Observable.bindNodeCallback = BoundNodeCallbackObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let bindNodeCallback: typeof BoundNodeCallbackObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/combineLatest.ts b/src/add/observable/combineLatest.ts index 023e169c93..5524e03fc4 100644 --- a/src/add/observable/combineLatest.ts +++ b/src/add/observable/combineLatest.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {combineLatestStatic} from '../../operator/combineLatest'; -Observable.combineLatest = combineLatestStatic; \ No newline at end of file +Observable.combineLatest = combineLatestStatic; + +declare module '../../Observable' { + namespace Observable { + export let combineLatest: typeof combineLatestStatic; + } +} \ No newline at end of file diff --git a/src/add/observable/concat.ts b/src/add/observable/concat.ts index 8165c322e1..19d85387d3 100644 --- a/src/add/observable/concat.ts +++ b/src/add/observable/concat.ts @@ -1,5 +1,10 @@ - import {Observable} from '../../Observable'; import {concatStatic} from '../../operator/concat'; -Observable.concat = concatStatic; \ No newline at end of file +Observable.concat = concatStatic; + +declare module '../../Observable' { + namespace Observable { + export let concat: typeof concatStatic; + } +} \ No newline at end of file diff --git a/src/add/observable/defer.ts b/src/add/observable/defer.ts index bc1af97b16..1d4bad605b 100644 --- a/src/add/observable/defer.ts +++ b/src/add/observable/defer.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {DeferObservable} from '../../observable/DeferObservable'; -Observable.defer = DeferObservable.create; \ No newline at end of file +Observable.defer = DeferObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let defer: typeof DeferObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/dom/ajax.ts b/src/add/observable/dom/ajax.ts index 1829e090d3..94eb79fb69 100644 --- a/src/add/observable/dom/ajax.ts +++ b/src/add/observable/dom/ajax.ts @@ -1,5 +1,10 @@ - import {Observable} from '../../../Observable'; import {AjaxObservable} from '../../../observable/dom/AjaxObservable'; -Observable.ajax = AjaxObservable.create; \ No newline at end of file +Observable.ajax = AjaxObservable.create; + +declare module '../../../Observable' { + namespace Observable { + export let ajax: typeof AjaxObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/dom/webSocket.ts b/src/add/observable/dom/webSocket.ts index 6b3fbf6968..e9e7de0f06 100644 --- a/src/add/observable/dom/webSocket.ts +++ b/src/add/observable/dom/webSocket.ts @@ -1,5 +1,10 @@ - import {Observable} from '../../../Observable'; import {WebSocketSubject} from '../../../observable/dom/WebSocketSubject'; -Observable.webSocket = WebSocketSubject.create; \ No newline at end of file +Observable.webSocket = WebSocketSubject.create; + +declare module '../../../Observable' { + namespace Observable { + export let webSocket: typeof WebSocketSubject.create; + } +} \ No newline at end of file diff --git a/src/add/observable/empty.ts b/src/add/observable/empty.ts index 2bf04010dd..82dbbc9df4 100644 --- a/src/add/observable/empty.ts +++ b/src/add/observable/empty.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {EmptyObservable} from '../../observable/EmptyObservable'; -Observable.empty = EmptyObservable.create; \ No newline at end of file +Observable.empty = EmptyObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let empty: typeof EmptyObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/forkJoin.ts b/src/add/observable/forkJoin.ts index 8c1a9e8f3b..8beb5f92c5 100644 --- a/src/add/observable/forkJoin.ts +++ b/src/add/observable/forkJoin.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {ForkJoinObservable} from '../../observable/ForkJoinObservable'; -Observable.forkJoin = ForkJoinObservable.create; \ No newline at end of file +Observable.forkJoin = ForkJoinObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let forkJoin: typeof ForkJoinObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/from.ts b/src/add/observable/from.ts index 6bada5e799..8fa6978aa7 100644 --- a/src/add/observable/from.ts +++ b/src/add/observable/from.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {FromObservable} from '../../observable/FromObservable'; -Observable.from = FromObservable.create; \ No newline at end of file +Observable.from = FromObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let from: typeof FromObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/fromArray.ts b/src/add/observable/fromArray.ts index ab9cb89783..848cf82d7b 100644 --- a/src/add/observable/fromArray.ts +++ b/src/add/observable/fromArray.ts @@ -1,5 +1,11 @@ import {Observable} from '../../Observable'; import {ArrayObservable} from '../../observable/ArrayObservable'; +import './of'; Observable.fromArray = ArrayObservable.create; -Observable.of = ArrayObservable.of; \ No newline at end of file + +declare module '../../Observable' { + namespace Observable { + export let fromArray: typeof ArrayObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/fromEvent.ts b/src/add/observable/fromEvent.ts index e8e9e3462d..49dc5d44ac 100644 --- a/src/add/observable/fromEvent.ts +++ b/src/add/observable/fromEvent.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {FromEventObservable} from '../../observable/FromEventObservable'; -Observable.fromEvent = FromEventObservable.create; \ No newline at end of file +Observable.fromEvent = FromEventObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let fromEvent: typeof FromEventObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/fromEventPattern.ts b/src/add/observable/fromEventPattern.ts index 9dbcaeaba0..b69af51518 100644 --- a/src/add/observable/fromEventPattern.ts +++ b/src/add/observable/fromEventPattern.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {FromEventPatternObservable} from '../../observable/FromEventPatternObservable'; -Observable.fromEventPattern = FromEventPatternObservable.create; \ No newline at end of file +Observable.fromEventPattern = FromEventPatternObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let fromEventPattern: typeof FromEventPatternObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/fromPromise.ts b/src/add/observable/fromPromise.ts index 1c9ffad4e4..70daeb53bd 100644 --- a/src/add/observable/fromPromise.ts +++ b/src/add/observable/fromPromise.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {PromiseObservable} from '../../observable/PromiseObservable'; -Observable.fromPromise = PromiseObservable.create; \ No newline at end of file +Observable.fromPromise = PromiseObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let fromPromise: typeof PromiseObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/interval.ts b/src/add/observable/interval.ts index 2c5dc45750..8aebb1ef57 100644 --- a/src/add/observable/interval.ts +++ b/src/add/observable/interval.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {IntervalObservable} from '../../observable/IntervalObservable'; -Observable.interval = IntervalObservable.create; \ No newline at end of file +Observable.interval = IntervalObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let interval: typeof IntervalObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/merge.ts b/src/add/observable/merge.ts index 72f7e3e246..adfd647969 100644 --- a/src/add/observable/merge.ts +++ b/src/add/observable/merge.ts @@ -1,5 +1,10 @@ - import {Observable} from '../../Observable'; import {mergeStatic} from '../../operator/merge'; -Observable.merge = mergeStatic; \ No newline at end of file +Observable.merge = mergeStatic; + +declare module '../../Observable' { + namespace Observable { + export let merge: typeof mergeStatic; + } +} \ No newline at end of file diff --git a/src/add/observable/never.ts b/src/add/observable/never.ts index a82d304736..f47b5468e3 100644 --- a/src/add/observable/never.ts +++ b/src/add/observable/never.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {NeverObservable} from '../../observable/NeverObservable'; -Observable.never = NeverObservable.create; \ No newline at end of file +Observable.never = NeverObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let never: typeof NeverObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/of.ts b/src/add/observable/of.ts index 3730de28a3..d98ae5d3a8 100644 --- a/src/add/observable/of.ts +++ b/src/add/observable/of.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {ArrayObservable} from '../../observable/ArrayObservable'; -Observable.of = ArrayObservable.of; \ No newline at end of file +Observable.of = ArrayObservable.of; + +declare module '../../Observable' { + namespace Observable { + export let of: typeof ArrayObservable.of; + } +} \ No newline at end of file diff --git a/src/add/observable/race.ts b/src/add/observable/race.ts index d15c625f90..eae4ecd7f4 100644 --- a/src/add/observable/race.ts +++ b/src/add/observable/race.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {raceStatic} from '../../operator/race'; -Observable.race = raceStatic; \ No newline at end of file +Observable.race = raceStatic; + +declare module '../../Observable' { + namespace Observable { + export let race: typeof raceStatic; + } +} \ No newline at end of file diff --git a/src/add/observable/range.ts b/src/add/observable/range.ts index d3cbaddb7e..fe0c1635be 100644 --- a/src/add/observable/range.ts +++ b/src/add/observable/range.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {RangeObservable} from '../../observable/RangeObservable'; -Observable.range = RangeObservable.create; \ No newline at end of file +Observable.range = RangeObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let range: typeof RangeObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/timer.ts b/src/add/observable/timer.ts index 06754b60f8..e970bd38a3 100644 --- a/src/add/observable/timer.ts +++ b/src/add/observable/timer.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {TimerObservable} from '../../observable/TimerObservable'; -Observable.timer = TimerObservable.create; \ No newline at end of file +Observable.timer = TimerObservable.create; + +declare module '../../Observable' { + namespace Observable { + export let timer: typeof TimerObservable.create; + } +} \ No newline at end of file diff --git a/src/add/observable/zip.ts b/src/add/observable/zip.ts index b49ad021c2..f98970dd09 100644 --- a/src/add/observable/zip.ts +++ b/src/add/observable/zip.ts @@ -1,4 +1,10 @@ import {Observable} from '../../Observable'; import {zipStatic} from '../../operator/zip'; -Observable.zip = zipStatic; \ No newline at end of file +Observable.zip = zipStatic; + +declare module '../../Observable' { + namespace Observable { + export let zip: typeof zipStatic; + } +} \ No newline at end of file