Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
876 bytes
|
Line | |
---|
1 | import { Subject } from './Subject';
|
---|
2 | import { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';
|
---|
3 | export class BehaviorSubject extends Subject {
|
---|
4 | constructor(_value) {
|
---|
5 | super();
|
---|
6 | this._value = _value;
|
---|
7 | }
|
---|
8 | get value() {
|
---|
9 | return this.getValue();
|
---|
10 | }
|
---|
11 | _subscribe(subscriber) {
|
---|
12 | const subscription = super._subscribe(subscriber);
|
---|
13 | if (subscription && !subscription.closed) {
|
---|
14 | subscriber.next(this._value);
|
---|
15 | }
|
---|
16 | return subscription;
|
---|
17 | }
|
---|
18 | getValue() {
|
---|
19 | if (this.hasError) {
|
---|
20 | throw this.thrownError;
|
---|
21 | }
|
---|
22 | else if (this.closed) {
|
---|
23 | throw new ObjectUnsubscribedError();
|
---|
24 | }
|
---|
25 | else {
|
---|
26 | return this._value;
|
---|
27 | }
|
---|
28 | }
|
---|
29 | next(value) {
|
---|
30 | super.next(this._value = value);
|
---|
31 | }
|
---|
32 | }
|
---|
33 | //# sourceMappingURL=BehaviorSubject.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.