Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

SubscribeOnObservable.js 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. import { Observable } from '../Observable';
  2. import { asap } from '../scheduler/asap';
  3. import { isNumeric } from '../util/isNumeric';
  4. export class SubscribeOnObservable extends Observable {
  5. constructor(source, delayTime = 0, scheduler = asap) {
  6. super();
  7. this.source = source;
  8. this.delayTime = delayTime;
  9. this.scheduler = scheduler;
  10. if (!isNumeric(delayTime) || delayTime < 0) {
  11. this.delayTime = 0;
  12. }
  13. if (!scheduler || typeof scheduler.schedule !== 'function') {
  14. this.scheduler = asap;
  15. }
  16. }
  17. static create(source, delay = 0, scheduler = asap) {
  18. return new SubscribeOnObservable(source, delay, scheduler);
  19. }
  20. static dispatch(arg) {
  21. const { source, subscriber } = arg;
  22. return this.add(source.subscribe(subscriber));
  23. }
  24. _subscribe(subscriber) {
  25. const delay = this.delayTime;
  26. const source = this.source;
  27. const scheduler = this.scheduler;
  28. return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
  29. source, subscriber
  30. });
  31. }
  32. }
  33. //# sourceMappingURL=SubscribeOnObservable.js.map