subscribeOn.js 982 B

123456789101112131415161718192021222324252627
  1. import { SubscribeOnObservable } from '../observable/SubscribeOnObservable';
  2. /**
  3. * Asynchronously subscribes Observers to this Observable on the specified IScheduler.
  4. *
  5. * <img src="./img/subscribeOn.png" width="100%">
  6. *
  7. * @param {Scheduler} scheduler - The IScheduler to perform subscription actions on.
  8. * @return {Observable<T>} The source Observable modified so that its subscriptions happen on the specified IScheduler.
  9. .
  10. * @method subscribeOn
  11. * @owner Observable
  12. */
  13. export function subscribeOn(scheduler, delay = 0) {
  14. return function subscribeOnOperatorFunction(source) {
  15. return source.lift(new SubscribeOnOperator(scheduler, delay));
  16. };
  17. }
  18. class SubscribeOnOperator {
  19. constructor(scheduler, delay) {
  20. this.scheduler = scheduler;
  21. this.delay = delay;
  22. }
  23. call(subscriber, source) {
  24. return new SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
  25. }
  26. }
  27. //# sourceMappingURL=subscribeOn.js.map