SubscribeOnObservable.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /** PURE_IMPORTS_START .._Observable,.._scheduler_asap,.._util_isNumeric PURE_IMPORTS_END */
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b)
  4. if (b.hasOwnProperty(p))
  5. d[p] = b[p];
  6. function __() { this.constructor = d; }
  7. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8. };
  9. import { Observable } from '../Observable';
  10. import { asap } from '../scheduler/asap';
  11. import { isNumeric } from '../util/isNumeric';
  12. /**
  13. * We need this JSDoc comment for affecting ESDoc.
  14. * @extends {Ignored}
  15. * @hide true
  16. */
  17. export var SubscribeOnObservable = /*@__PURE__*/ (/*@__PURE__*/ function (_super) {
  18. __extends(SubscribeOnObservable, _super);
  19. function SubscribeOnObservable(source, delayTime, scheduler) {
  20. if (delayTime === void 0) {
  21. delayTime = 0;
  22. }
  23. if (scheduler === void 0) {
  24. scheduler = asap;
  25. }
  26. _super.call(this);
  27. this.source = source;
  28. this.delayTime = delayTime;
  29. this.scheduler = scheduler;
  30. if (!isNumeric(delayTime) || delayTime < 0) {
  31. this.delayTime = 0;
  32. }
  33. if (!scheduler || typeof scheduler.schedule !== 'function') {
  34. this.scheduler = asap;
  35. }
  36. }
  37. SubscribeOnObservable.create = function (source, delay, scheduler) {
  38. if (delay === void 0) {
  39. delay = 0;
  40. }
  41. if (scheduler === void 0) {
  42. scheduler = asap;
  43. }
  44. return new SubscribeOnObservable(source, delay, scheduler);
  45. };
  46. SubscribeOnObservable.dispatch = function (arg) {
  47. var source = arg.source, subscriber = arg.subscriber;
  48. return this.add(source.subscribe(subscriber));
  49. };
  50. /** @deprecated internal use only */ SubscribeOnObservable.prototype._subscribe = function (subscriber) {
  51. var delay = this.delayTime;
  52. var source = this.source;
  53. var scheduler = this.scheduler;
  54. return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
  55. source: source, subscriber: subscriber
  56. });
  57. };
  58. return SubscribeOnObservable;
  59. }(Observable));
  60. //# sourceMappingURL=SubscribeOnObservable.js.map