Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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