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

SubjectSubscription.js 823B

1234567891011121314151617181920212223242526
  1. import { Subscription } from './Subscription';
  2. export class SubjectSubscription extends Subscription {
  3. constructor(subject, subscriber) {
  4. super();
  5. this.subject = subject;
  6. this.subscriber = subscriber;
  7. this.closed = false;
  8. }
  9. unsubscribe() {
  10. if (this.closed) {
  11. return;
  12. }
  13. this.closed = true;
  14. const subject = this.subject;
  15. const observers = subject.observers;
  16. this.subject = null;
  17. if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
  18. return;
  19. }
  20. const subscriberIndex = observers.indexOf(this.subscriber);
  21. if (subscriberIndex !== -1) {
  22. observers.splice(subscriberIndex, 1);
  23. }
  24. }
  25. }
  26. //# sourceMappingURL=SubjectSubscription.js.map