Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
823 bytes
|
Line | |
---|
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 |
---|
Note:
See
TracBrowser
for help on using the repository browser.