import { Operator } from '../Operator'; import { Scheduler } from '../Scheduler'; import { Subscriber } from '../Subscriber'; import { Observable } from '../Observable'; import { TeardownLogic } from '../Subscription'; import { SubscribeOnObservable } from '../observable/SubscribeOnObservable'; /** * Asynchronously subscribes Observers to this Observable on the specified Scheduler. * * * * @param {Scheduler} the Scheduler to perform subscription actions on. * @return {Observable} the source Observable modified so that its subscriptions happen on the specified Scheduler . * @method subscribeOn * @owner Observable */ export function subscribeOn(this: Observable, scheduler: Scheduler, delay: number = 0): Observable { return this.lift(new SubscribeOnOperator(scheduler, delay)); } class SubscribeOnOperator implements Operator { constructor(private scheduler: Scheduler, private delay: number) { } call(subscriber: Subscriber, source: any): TeardownLogic { return new SubscribeOnObservable( source, this.delay, this.scheduler ).subscribe(subscriber); } }