Skip to content

Commit

Permalink
refactor(operators): substitute asap for async scheduler as default i…
Browse files Browse the repository at this point in the history
…n operators
  • Loading branch information
trxcllnt committed Mar 2, 2016
1 parent 7607305 commit 8da54f6
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion spec/observables/interval-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Observable.interval', () => {
it('should specify default scheduler if incorrect scheduler specified', () => {
const scheduler = (<any>Observable.interval(10, <any>jasmine.createSpy('dummy'))).scheduler;

expect(scheduler).toBe(Rx.Scheduler.asap);
expect(scheduler).toBe(Rx.Scheduler.async);
});

it('should emit when relative interval set to zero', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/observable/IntervalObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {Subscriber} from '../Subscriber';
import {isNumeric} from '../util/isNumeric';
import {Scheduler} from '../Scheduler';
import {Observable} from '../Observable';
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';

export class IntervalObservable extends Observable<number> {
static create(period: number = 0, scheduler: Scheduler = asap): Observable<number> {
static create(period: number = 0, scheduler: Scheduler = async): Observable<number> {
return new IntervalObservable(period, scheduler);
}

Expand All @@ -23,13 +23,13 @@ export class IntervalObservable extends Observable<number> {
(<any> this).schedule(state, period);
}

constructor(private period: number = 0, private scheduler: Scheduler = asap) {
constructor(private period: number = 0, private scheduler: Scheduler = async) {
super();
if (!isNumeric(period) || period < 0) {
this.period = 0;
}
if (!scheduler || typeof scheduler.schedule !== 'function') {
this.scheduler = asap;
this.scheduler = async;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/observable/TimerObservable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {isNumeric} from '../util/isNumeric';
import {Scheduler} from '../Scheduler';
import {Observable} from '../Observable';
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';
import {isScheduler} from '../util/isScheduler';
import {isDate} from '../util/isDate';
import {Subscription} from '../Subscription';
Expand Down Expand Up @@ -46,7 +46,7 @@ export class TimerObservable extends Observable<number> {
}

if (!isScheduler(scheduler)) {
scheduler = asap;
scheduler = async;
}

this.scheduler = scheduler;
Expand Down
6 changes: 3 additions & 3 deletions src/operator/bufferTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Subscriber} from '../Subscriber';
import {Observable} from '../Observable';
import {Scheduler} from '../Scheduler';
import {Action} from '../scheduler/Action';
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';

/**
* Buffers values from the source for a specific time period. Optionally allows
Expand All @@ -15,14 +15,14 @@ import {asap} from '../scheduler/asap';
* before emitting them and clearing them.
* @param {number} [bufferCreationInterval] the interval at which to start new
* buffers.
* @param {Scheduler} [scheduler] (optional, defaults to `asap` scheduler) The
* @param {Scheduler} [scheduler] (optional, defaults to `async` scheduler) The
* scheduler on which to schedule the intervals that determine buffer
* boundaries.
* @returns {Observable<T[]>} an observable of arrays of buffered values.
*/
export function bufferTime<T>(bufferTimeSpan: number,
bufferCreationInterval: number = null,
scheduler: Scheduler = asap): Observable<T[]> {
scheduler: Scheduler = async): Observable<T[]> {
return this.lift(new BufferTimeOperator<T>(bufferTimeSpan, bufferCreationInterval, scheduler));
}

Expand Down
4 changes: 2 additions & 2 deletions src/operator/debounceTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Observable} from '../Observable';
import {Subscriber} from '../Subscriber';
import {Scheduler} from '../Scheduler';
import {Subscription} from '../Subscription';
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';

/**
* Returns the source Observable delayed by the computed debounce duration,
Expand All @@ -17,7 +17,7 @@ import {asap} from '../scheduler/asap';
* @param {Scheduler} [scheduler] the Scheduler to use for managing the timers that handle the timeout for each item.
* @returns {Observable} an Observable the same as source Observable, but drops items.
*/
export function debounceTime<T>(dueTime: number, scheduler: Scheduler = asap): Observable<T> {
export function debounceTime<T>(dueTime: number, scheduler: Scheduler = async): Observable<T> {
return this.lift(new DebounceTimeOperator(dueTime, scheduler));
}

Expand Down
4 changes: 2 additions & 2 deletions src/operator/delay.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';
import {isDate} from '../util/isDate';
import {Operator} from '../Operator';
import {Scheduler} from '../Scheduler';
Expand All @@ -14,7 +14,7 @@ import {Observable} from '../Observable';
* @returns {Observable} an Observable that delays the emissions of the source Observable by the specified timeout or Date.
*/
export function delay<T>(delay: number|Date,
scheduler: Scheduler = asap): Observable<T> {
scheduler: Scheduler = async): Observable<T> {
const absoluteDelay = isDate(delay);
const delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(<number>delay);
return this.lift(new DelayOperator(delayFor, scheduler));
Expand Down
4 changes: 2 additions & 2 deletions src/operator/inspectTime.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';
import {Operator} from '../Operator';
import {Scheduler} from '../Scheduler';
import {Subscriber} from '../Subscriber';
import {Observable} from '../Observable';
import {Subscription} from '../Subscription';

export function inspectTime<T>(delay: number, scheduler: Scheduler = asap): Observable<T> {
export function inspectTime<T>(delay: number, scheduler: Scheduler = async): Observable<T> {
return this.lift(new InspectTimeOperator(delay, scheduler));
}

Expand Down
4 changes: 2 additions & 2 deletions src/operator/sampleTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {Observable} from '../Observable';
import {Operator} from '../Operator';
import {Subscriber} from '../Subscriber';
import {Scheduler} from '../Scheduler';
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';

export function sampleTime<T>(delay: number, scheduler: Scheduler = asap): Observable<T> {
export function sampleTime<T>(delay: number, scheduler: Scheduler = async): Observable<T> {
return this.lift(new SampleTimeOperator(delay, scheduler));
}

Expand Down
4 changes: 2 additions & 2 deletions src/operator/throttleTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {Operator} from '../Operator';
import {Subscriber} from '../Subscriber';
import {Scheduler} from '../Scheduler';
import {Subscription} from '../Subscription';
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';
import {Observable} from '../Observable';

export function throttleTime<T>(delay: number, scheduler: Scheduler = asap): Observable<T> {
export function throttleTime<T>(delay: number, scheduler: Scheduler = async): Observable<T> {
return this.lift(new ThrottleTimeOperator(delay, scheduler));
}

Expand Down
4 changes: 2 additions & 2 deletions src/operator/timeInterval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {Operator} from '../Operator';
import {Observable} from '../Observable';
import {Subscriber} from '../Subscriber';
import {Scheduler} from '../Scheduler';
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';

export function timeInterval<T>(scheduler: Scheduler = asap): Observable<TimeInterval<T>> {
export function timeInterval<T>(scheduler: Scheduler = async): Observable<TimeInterval<T>> {
return this.lift(new TimeIntervalOperator(scheduler));
}

Expand Down
4 changes: 2 additions & 2 deletions src/operator/timeout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';
import {isDate} from '../util/isDate';
import {Operator} from '../Operator';
import {Subscriber} from '../Subscriber';
Expand All @@ -7,7 +7,7 @@ import {Observable} from '../Observable';

export function timeout<T>(due: number | Date,
errorToSend: any = null,
scheduler: Scheduler = asap): Observable<T> {
scheduler: Scheduler = async): Observable<T> {
let absoluteTimeout = isDate(due);
let waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(<number>due);
return this.lift(new TimeoutOperator(waitFor, absoluteTimeout, errorToSend, scheduler));
Expand Down
4 changes: 2 additions & 2 deletions src/operator/timeoutWith.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Operator} from '../Operator';
import {Subscriber} from '../Subscriber';
import {Scheduler} from '../Scheduler';
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';
import {Subscription} from '../Subscription';
import {Observable} from '../Observable';
import {isDate} from '../util/isDate';
Expand All @@ -10,7 +10,7 @@ import {subscribeToResult} from '../util/subscribeToResult';

export function timeoutWith<T, R>(due: number | Date,
withObservable: Observable<R>,
scheduler: Scheduler = asap): Observable<T | R> {
scheduler: Scheduler = async): Observable<T | R> {
let absoluteTimeout = isDate(due);
let waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(<number>due);
return this.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
Expand Down
4 changes: 2 additions & 2 deletions src/operator/windowTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {Observable} from '../Observable';
import {Subject} from '../Subject';
import {Scheduler} from '../Scheduler';
import {Action} from '../scheduler/Action';
import {asap} from '../scheduler/asap';
import {async} from '../scheduler/async';

export function windowTime<T>(windowTimeSpan: number,
windowCreationInterval: number = null,
scheduler: Scheduler = asap): Observable<Observable<T>> {
scheduler: Scheduler = async): Observable<Observable<T>> {
return this.lift(new WindowTimeOperator<T>(windowTimeSpan, windowCreationInterval, scheduler));
}

Expand Down

0 comments on commit 8da54f6

Please sign in to comment.