1 | "use strict";
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = Object.setPrototypeOf ||
|
4 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
6 | return function (d, b) {
|
7 | extendStatics(d, b);
|
8 | function __() { this.constructor = d; }
|
9 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
10 | };
|
11 | })();
|
12 | Object.defineProperty(exports, "__esModule", { value: true });
|
13 | var Subject_1 = require("./Subject");
|
14 | var Subscription_1 = require("./Subscription");
|
15 | var AsyncSubject = (function (_super) {
|
16 | __extends(AsyncSubject, _super);
|
17 | function AsyncSubject() {
|
18 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
19 | _this.value = null;
|
20 | _this.hasNext = false;
|
21 | _this.hasCompleted = false;
|
22 | return _this;
|
23 | }
|
24 | AsyncSubject.prototype._subscribe = function (subscriber) {
|
25 | if (this.hasError) {
|
26 | subscriber.error(this.thrownError);
|
27 | return Subscription_1.Subscription.EMPTY;
|
28 | }
|
29 | else if (this.hasCompleted && this.hasNext) {
|
30 | subscriber.next(this.value);
|
31 | subscriber.complete();
|
32 | return Subscription_1.Subscription.EMPTY;
|
33 | }
|
34 | return _super.prototype._subscribe.call(this, subscriber);
|
35 | };
|
36 | AsyncSubject.prototype.next = function (value) {
|
37 | if (!this.hasCompleted) {
|
38 | this.value = value;
|
39 | this.hasNext = true;
|
40 | }
|
41 | };
|
42 | AsyncSubject.prototype.error = function (error) {
|
43 | if (!this.hasCompleted) {
|
44 | _super.prototype.error.call(this, error);
|
45 | }
|
46 | };
|
47 | AsyncSubject.prototype.complete = function () {
|
48 | this.hasCompleted = true;
|
49 | if (this.hasNext) {
|
50 | _super.prototype.next.call(this, this.value);
|
51 | }
|
52 | _super.prototype.complete.call(this);
|
53 | };
|
54 | return AsyncSubject;
|
55 | }(Subject_1.Subject));
|
56 | exports.AsyncSubject = AsyncSubject;
|
57 |
|
\ | No newline at end of file |