Skip to content

Commit

Permalink
refactor(operator): remove Observable-patching side effect from opera…
Browse files Browse the repository at this point in the history
…tors
  • Loading branch information
jeffbcross committed Dec 4, 2015
1 parent 4739266 commit 70f7aa8
Show file tree
Hide file tree
Showing 90 changed files with 2 additions and 232 deletions.
2 changes: 0 additions & 2 deletions src/operator/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,3 @@ class BufferClosingNotifierSubscriber<T> extends Subscriber<T> {
this.parent.complete();
}
}

Observable.prototype.buffer = buffer;
2 changes: 0 additions & 2 deletions src/operator/bufferCount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,3 @@ class BufferCountSubscriber<T> extends Subscriber<T> {
destination.complete();
}
}

Observable.prototype.bufferCount = bufferCount;
2 changes: 0 additions & 2 deletions src/operator/bufferTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,3 @@ function dispatchBufferCreation(state) {
function dispatchBufferClose({ subscriber, buffer }) {
subscriber.closeBuffer(buffer);
}

Observable.prototype.bufferTime = bufferTime;
2 changes: 0 additions & 2 deletions src/operator/bufferToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,3 @@ class BufferToggleClosingsSubscriber<T> extends Subscriber<T> {
this.parent.closeBuffer(this.context);
}
}

Observable.prototype.bufferToggle = bufferToggle;
2 changes: 0 additions & 2 deletions src/operator/bufferWhen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,3 @@ class BufferClosingNotifierSubscriber<T> extends Subscriber<T> {
this.parent.openBuffer();
}
}

Observable.prototype.bufferWhen = bufferWhen;
2 changes: 0 additions & 2 deletions src/operator/catch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,3 @@ class CatchSubscriber<T> extends Subscriber<T> {
this.lastSubscription.unsubscribe();
}
}

Observable.prototype.catch = _catch;
3 changes: 0 additions & 3 deletions src/operator/combineAll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {CombineLatestOperator} from './combineLatest-support';
import {Observable} from '../Observable';

/**
* Takes an Observable of Observables, and collects all observables from it. Once the outer observable
Expand All @@ -16,5 +15,3 @@ import {Observable} from '../Observable';
export function combineAll<T, R>(project?: (...values: Array<any>) => R) {
return this.lift(new CombineLatestOperator(project));
}

Observable.prototype.combineAll = combineAll;
2 changes: 0 additions & 2 deletions src/operator/combineLatest-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@ export function combineLatest<R>(...observables: Array<Observable<any> |

return new ArrayObservable(observables, scheduler).lift(new CombineLatestOperator(project));
}

Observable.combineLatest = combineLatest;
2 changes: 0 additions & 2 deletions src/operator/combineLatest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@ export function combineLatest<R>(...observables: Array<Observable<any> |

return new ArrayObservable(observables).lift(new CombineLatestOperator(project));
}

Observable.prototype.combineLatest = combineLatest;
2 changes: 0 additions & 2 deletions src/operator/concat-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ export function concat<R>(...observables: Array<Observable<any> | Scheduler>): O

return new ArrayObservable(observables, scheduler).lift(new MergeAllOperator(1));
}

Observable.concat = concat;
2 changes: 0 additions & 2 deletions src/operator/concat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ export function concat<R>(...observables: (Observable<any> | Scheduler)[]): Obse

return new ArrayObservable(args, scheduler).lift(new MergeAllOperator(1));
}

Observable.prototype.concat = concat;
2 changes: 0 additions & 2 deletions src/operator/concatAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ import {MergeAllOperator} from './mergeAll-support';
export function concatAll<T>(): Observable<T> {
return this.lift(new MergeAllOperator(1));
}

Observable.prototype.concatAll = concatAll;
2 changes: 0 additions & 2 deletions src/operator/concatMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,3 @@ export function concatMap<T, R>(project: (value: T, index: number) => Observable
projectResult?: (outerValue: T, innerValue: any, outerIndex: number, innerIndex: number) => R) {
return this.lift(new MergeMapOperator(project, projectResult, 1));
}

Observable.prototype.concatMap = concatMap;
2 changes: 0 additions & 2 deletions src/operator/concatMapTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ export function concatMapTo<T, R, R2>(observable: Observable<R>,
innerIndex: number) => R2): Observable<R2> {
return this.lift(new MergeMapToOperator(observable, projectResult, 1));
}

Observable.prototype.concatMapTo = concatMapTo;
2 changes: 0 additions & 2 deletions src/operator/count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,3 @@ class CountSubscriber<T, R> extends Subscriber<T> {
this.destination.complete();
}
}

Observable.prototype.count = count;
2 changes: 0 additions & 2 deletions src/operator/debounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,3 @@ class DurationSelectorSubscriber<T> extends Subscriber<T> {
this.debounceNext();
}
}

Observable.prototype.debounce = debounce;
2 changes: 0 additions & 2 deletions src/operator/debounceTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,3 @@ class DebounceTimeSubscriber<T> extends Subscriber<T> {
function dispatchNext(subscriber) {
subscriber.debouncedNext();
}

Observable.prototype.debounceTime = debounceTime;
2 changes: 0 additions & 2 deletions src/operator/defaultIfEmpty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ class DefaultIfEmptySubscriber<T, R> extends Subscriber<T> {
this.destination.complete();
}
}

Observable.prototype.defaultIfEmpty = defaultIfEmpty;
3 changes: 0 additions & 3 deletions src/operator/delay.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Operator} from '../Operator';
import {Observable} from '../Observable';
import {Scheduler} from '../Scheduler';
import {Subscriber} from '../Subscriber';
import {Notification} from '../Notification';
Expand Down Expand Up @@ -93,5 +92,3 @@ class DelayMessage<T> {
private notification: any) {
}
}

Observable.prototype.delay = delay;
2 changes: 0 additions & 2 deletions src/operator/dematerialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ class DeMaterializeSubscriber<T extends Notification<any>> extends Subscriber<T>
value.observe(this.destination);
}
}

Observable.prototype.dematerialize = dematerialize;
3 changes: 0 additions & 3 deletions src/operator/distinctUntilChanged.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Operator} from '../Operator';
import {Observable} from '../Observable';
import {Subscriber} from '../Subscriber';
import {tryCatch} from '../util/tryCatch';
import {errorObject} from '../util/errorObject';
Expand Down Expand Up @@ -60,5 +59,3 @@ class DistinctUntilChangedSubscriber<T> extends Subscriber<T> {
}
}
}

Observable.prototype.distinctUntilChanged = distinctUntilChanged;
3 changes: 0 additions & 3 deletions src/operator/do.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Operator} from '../Operator';
import {Observable} from '../Observable';
import {Observer} from '../Observer';
import {Subscriber} from '../Subscriber';

Expand Down Expand Up @@ -76,5 +75,3 @@ class DoSubscriber<T> extends Subscriber<T> {
}
}
}

Observable.prototype.do = _do;
2 changes: 0 additions & 2 deletions src/operator/every.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,3 @@ class EverySubscriber<T, R> extends Subscriber<T> {
this.notifyComplete(true);
}
}

Observable.prototype.every = every;
2 changes: 0 additions & 2 deletions src/operator/expand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ export function expand<T, R>(project: (value: T, index: number) => Observable<R>
concurrent: number = Number.POSITIVE_INFINITY): Observable<R> {
return this.lift(new ExpandOperator(project, concurrent));
}

Observable.prototype.expand = expand;
6 changes: 0 additions & 6 deletions src/operator/extended/distinctUntilKeyChanged.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {distinctUntilChanged} from '../distinctUntilChanged';
import {Observable} from '../../Observable';
import {KitchenSinkOperators} from '../../Rx.KitchenSink';

const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);

export function distinctUntilKeyChanged<T>(key: string, compare?: (x: any, y: any) => boolean, thisArg?: any) {
return distinctUntilChanged.call(this, function(x, y) {
Expand All @@ -12,5 +8,3 @@ export function distinctUntilKeyChanged<T>(key: string, compare?: (x: any, y: an
return x[key] === y[key];
});
}

observableProto.distinctUntilKeyChanged = distinctUntilKeyChanged;
6 changes: 0 additions & 6 deletions src/operator/extended/elementAt.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import {Operator} from '../../Operator';
import {Subscriber} from '../../Subscriber';
import {ArgumentOutOfRangeError} from '../../util/ArgumentOutOfRangeError';
import {Observable} from '../../Observable';
import {KitchenSinkOperators} from '../../Rx.KitchenSink';

const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);

export function elementAt(index: number, defaultValue?: any) {
return this.lift(new ElementAtOperator(index, defaultValue));
Expand Down Expand Up @@ -48,5 +44,3 @@ class ElementAtSubscriber<T, R> extends Subscriber<T> {
destination.complete();
}
}

observableProto.elementAt = elementAt;
5 changes: 0 additions & 5 deletions src/operator/extended/find.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import {FindValueOperator} from './find-support';
import {Observable} from '../../Observable';
import {KitchenSinkOperators} from '../../Rx.KitchenSink';

const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);

export function find<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean, thisArg?: any): Observable<T> {
return this.lift(new FindValueOperator(predicate, this, false, thisArg));
}

observableProto.find = find;
5 changes: 0 additions & 5 deletions src/operator/extended/findIndex.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import {Observable} from '../../Observable';
import {FindValueOperator} from './find-support';
import {KitchenSinkOperators} from '../../Rx.KitchenSink';

const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);

export function findIndex<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean, thisArg?: any): Observable<number> {
return this.lift(new FindValueOperator(predicate, this, true, thisArg));
}

observableProto.findIndex = findIndex;
6 changes: 0 additions & 6 deletions src/operator/extended/isEmpty.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {Operator} from '../../Operator';
import {Subscriber} from '../../Subscriber';
import {Observable} from '../../Observable';
import {KitchenSinkOperators} from '../../Rx.KitchenSink';

const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);

export function isEmpty() {
return this.lift(new IsEmptyOperator());
Expand Down Expand Up @@ -36,5 +32,3 @@ class IsEmptySubscriber<T> extends Subscriber<T> {
this.notifyComplete(true);
}
}

observableProto.isEmpty = isEmpty;
5 changes: 0 additions & 5 deletions src/operator/extended/max.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import {Observable} from '../../Observable';
import {ReduceOperator} from '../reduce-support';
import {KitchenSinkOperators} from '../../Rx.KitchenSink';

const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);

export function max<T, R>(comparer?: (x: R, y: T) => R): Observable<R> {
const max = (typeof comparer === 'function')
? comparer
: (x, y) => x > y ? x : y;
return this.lift(new ReduceOperator(max));
}

observableProto.max = max;
5 changes: 0 additions & 5 deletions src/operator/extended/mergeScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import {tryCatch} from '../../util/tryCatch';
import {errorObject} from '../../util/errorObject';
import {subscribeToResult} from '../../util/subscribeToResult';
import {OuterSubscriber} from '../../OuterSubscriber';
import {KitchenSinkOperators} from '../../Rx.KitchenSink';

const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);

export function mergeScan<T, R>(project: (acc: R, x: T) => Observable<R>, seed: R) {
return this.lift(new MergeScanOperator(project, seed));
Expand Down Expand Up @@ -92,5 +89,3 @@ export class MergeScanSubscriber<T, R> extends OuterSubscriber<T, R> {
}
}
}

observableProto.mergeScan = mergeScan;
5 changes: 0 additions & 5 deletions src/operator/extended/min.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import {Observable} from '../../Observable';
import {ReduceOperator} from '../reduce-support';
import {KitchenSinkOperators} from '../../Rx.KitchenSink';

const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);

export function min<T, R>(comparer?: (x: R, y: T) => R): Observable<R> {
const min = (typeof comparer === 'function')
? comparer
: (x, y) => x < y ? x : y;
return this.lift(new ReduceOperator(min));
}

observableProto.min = min;
5 changes: 0 additions & 5 deletions src/operator/extended/timeInterval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import {Observable} from '../../Observable';
import {Subscriber} from '../../Subscriber';
import {Scheduler} from '../../Scheduler';
import {immediate} from '../../scheduler/immediate';
import {KitchenSinkOperators} from '../../Rx.KitchenSink';

const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);

export function timeInterval<T>(scheduler: Scheduler = immediate): Observable<TimeInterval> {
return this.lift(new TimeIntervalOperator(scheduler));
Expand Down Expand Up @@ -44,5 +41,3 @@ class TimeIntervalSubscriber<TimeInterval> extends Subscriber<TimeInterval> {
this.destination.next(new TimeInterval(value, span));
}
}

observableProto.timeInterval = timeInterval;
5 changes: 1 addition & 4 deletions src/operator/filter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Operator} from '../Operator';
import {Observable} from '../Observable';
import {Subscriber} from '../Subscriber';
import {tryCatch} from '../util/tryCatch';
import {errorObject} from '../util/errorObject';
Expand All @@ -8,7 +7,7 @@ import {bindCallback} from '../util/bindCallback';
/**
* Similar to the well-known `Array.prototype.filter` method, this operator filters values down to a set
* allowed by a `select` function
*
*
* @param {Function} select a function that is used to select the resulting values
* if it returns `true`, the value is emitted, if `false` the value is not passed to the resulting observable
* @param {any} [thisArg] an optional argument to determine the value of `this` in the `select` function
Expand Down Expand Up @@ -50,5 +49,3 @@ class FilterSubscriber<T> extends Subscriber<T> {
}
}
}

Observable.prototype.filter = filter;
3 changes: 0 additions & 3 deletions src/operator/finally.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Operator} from '../Operator';
import {Observable} from '../Observable';
import {Subscriber} from '../Subscriber';
import {Subscription} from '../Subscription';
import {bindCallback} from '../util/bindCallback';
Expand Down Expand Up @@ -29,5 +28,3 @@ class FinallySubscriber<T> extends Subscriber<T> {
this.add(new Subscription(finallySelector));
}
}

Observable.prototype.finally = _finally;
2 changes: 0 additions & 2 deletions src/operator/first.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,3 @@ class FirstSubscriber<T, R> extends Subscriber<T> {
}
}
}

Observable.prototype.first = first;
2 changes: 0 additions & 2 deletions src/operator/groupBy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,3 @@ class GroupDurationSubscriber<T> extends Subscriber<T> {
this.parent.removeGroup(this.key);
}
}

Observable.prototype.groupBy = groupBy;
3 changes: 0 additions & 3 deletions src/operator/ignoreElements.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Operator} from '../Operator';
import {Observable} from '../Observable';
import {Subscriber} from '../Subscriber';
import {noop} from '../util/noop';

Expand All @@ -18,5 +17,3 @@ class IgnoreElementsSubscriber<T> extends Subscriber<T> {
noop();
}
}

Observable.prototype.ignoreElements = ignoreElements;
2 changes: 0 additions & 2 deletions src/operator/last.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,3 @@ class LastSubscriber<T, R> extends Subscriber<T> {
}
}
}

Observable.prototype.last = last;
Loading

0 comments on commit 70f7aa8

Please sign in to comment.