source: trip-planner-front/node_modules/rxjs/src/internal/SubjectSubscription.ts@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 846 bytes
Line 
1import { Subject } from './Subject';
2import { Observer } from './types';
3import { Subscription } from './Subscription';
4
5/**
6 * We need this JSDoc comment for affecting ESDoc.
7 * @ignore
8 * @extends {Ignored}
9 */
10export class SubjectSubscription<T> extends Subscription {
11 closed: boolean = false;
12
13 constructor(public subject: Subject<T>, public subscriber: Observer<T>) {
14 super();
15 }
16
17 unsubscribe() {
18 if (this.closed) {
19 return;
20 }
21
22 this.closed = true;
23
24 const subject = this.subject;
25 const observers = subject.observers;
26
27 this.subject = null;
28
29 if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
30 return;
31 }
32
33 const subscriberIndex = observers.indexOf(this.subscriber);
34
35 if (subscriberIndex !== -1) {
36 observers.splice(subscriberIndex, 1);
37 }
38 }
39}
Note: See TracBrowser for help on using the repository browser.