1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.Subject = exports.Observable = void 0;
|
4 | const observable_fns_1 = require("observable-fns");
|
5 | Object.defineProperty(exports, "Observable", { enumerable: true, get: function () { return observable_fns_1.Observable; } });
|
6 | const $observers = Symbol("observers");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | class Subject extends observable_fns_1.Observable {
|
17 | constructor() {
|
18 | super(observer => {
|
19 | this[$observers] = [
|
20 | ...(this[$observers] || []),
|
21 | observer
|
22 | ];
|
23 | const unsubscribe = () => {
|
24 | this[$observers] = this[$observers].filter(someObserver => someObserver !== observer);
|
25 | };
|
26 | return unsubscribe;
|
27 | });
|
28 | this[$observers] = [];
|
29 | }
|
30 | complete() {
|
31 | this[$observers].forEach(observer => observer.complete());
|
32 | }
|
33 | error(error) {
|
34 | this[$observers].forEach(observer => observer.error(error));
|
35 | }
|
36 | next(value) {
|
37 | this[$observers].forEach(observer => observer.next(value));
|
38 | }
|
39 | }
|
40 | exports.Subject = Subject;
|