Front end of the Slack clone application.

SubjectSubscription.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 Subscription_1 = require('./Subscription');
  8. /**
  9. * We need this JSDoc comment for affecting ESDoc.
  10. * @ignore
  11. * @extends {Ignored}
  12. */
  13. var SubjectSubscription = (function (_super) {
  14. __extends(SubjectSubscription, _super);
  15. function SubjectSubscription(subject, subscriber) {
  16. _super.call(this);
  17. this.subject = subject;
  18. this.subscriber = subscriber;
  19. this.closed = false;
  20. }
  21. SubjectSubscription.prototype.unsubscribe = function () {
  22. if (this.closed) {
  23. return;
  24. }
  25. this.closed = true;
  26. var subject = this.subject;
  27. var observers = subject.observers;
  28. this.subject = null;
  29. if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
  30. return;
  31. }
  32. var subscriberIndex = observers.indexOf(this.subscriber);
  33. if (subscriberIndex !== -1) {
  34. observers.splice(subscriberIndex, 1);
  35. }
  36. };
  37. return SubjectSubscription;
  38. }(Subscription_1.Subscription));
  39. exports.SubjectSubscription = SubjectSubscription;
  40. //# sourceMappingURL=SubjectSubscription.js.map