Skip to content

Commit

Permalink
refactor(operators): remove circular reference using ambient merge
Browse files Browse the repository at this point in the history
- remove circular references using
  microsoft/TypeScript#3332, parents are
references children via ambient interfaces and let compiler merges it
  • Loading branch information
kwonoj committed Dec 7, 2015
1 parent d5adbd4 commit 10c5707
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/CoreOperators.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {Observable} from './Observable';
import {Scheduler} from './Scheduler';
import {ConnectableObservable} from './observable/ConnectableObservable';
import {Subject} from './Subject';
import {GroupedObservable} from './operator/groupBy-support';
import {Notification} from './Notification';

import {Observable} from './ambient/Observable';
import {Subject} from './ambient/Subject';
import {GroupedObservable} from './ambient/GroupedObservable';
import {ConnectableObservable} from './ambient/ConnectableObservable';

export interface CoreOperators<T> {
buffer?: (closingNotifier: Observable<any>) => Observable<T[]>;
bufferCount?: (bufferSize: number, startBufferEvery: number) => Observable<T[]>;
Expand Down
15 changes: 11 additions & 4 deletions src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {Subscription} from './Subscription';
import {root} from './util/root';
import {CoreOperators} from './CoreOperators';
import {SymbolShim} from './util/SymbolShim';
import {GroupedObservable} from './operator/groupBy-support';
import {ConnectableObservable} from './observable/ConnectableObservable';
import {Subject} from './Subject';
import {Notification} from './Notification';

import {Subject} from './ambient/Subject';
import {GroupedObservable} from './ambient/GroupedObservable';
import {ConnectableObservable} from './ambient/ConnectableObservable';

/**
* A representation of any set of values over any amount of time. This the most basic building block
* of RxJS.
Expand Down Expand Up @@ -89,7 +90,7 @@ export class Observable<T> implements CoreOperators<T> {
let subscriber: Subscriber<T>;

if (observerOrNext && typeof observerOrNext === 'object') {
if (observerOrNext instanceof Subscriber || observerOrNext instanceof Subject) {
if (observerOrNext instanceof Subscriber) { //|| observerOrNext instanceof Subject) {
subscriber = (<Subscriber<T>> observerOrNext);
} else {
subscriber = new Subscriber(<Observer<T>> observerOrNext);
Expand Down Expand Up @@ -255,3 +256,9 @@ export class Observable<T> implements CoreOperators<T> {
zip: <R>(...observables: Array<Observable<any> | ((...values: Array<any>) => R)>) => Observable<R>;
zipAll: <R>(project?: (...values: Array<any>) => R) => Observable<R>;
}

//let import occurs after Observable<T> is exported
import {ArrayObservable} from './observable/fromArray';

Observable.fromArray = ArrayObservable.create;
Observable.of = ArrayObservable.of;
1 change: 1 addition & 0 deletions src/ambient/ConnectableObservable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export interface ConnectableObservable<T> {}
1 change: 1 addition & 0 deletions src/ambient/GroupedObservable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export interface GroupedObservable<T> {}
1 change: 1 addition & 0 deletions src/ambient/Observable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export interface Observable<T> {}
1 change: 1 addition & 0 deletions src/ambient/Subject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export interface Subject<T> {}

0 comments on commit 10c5707

Please sign in to comment.