SubscribeOnObservable.js 2.1 KB

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