| 1 |
import { Subject } from './Subject'; |
| 2 |
export class AsyncSubject extends Subject { |
| 3 |
constructor() { |
| 4 |
super(...arguments); |
| 5 |
this._value = null; |
| 6 |
this._hasValue = false; |
| 7 |
this._isComplete = false; |
| 8 |
} |
| 9 |
_checkFinalizedStatuses(subscriber) { |
| 10 |
const { hasError, _hasValue, _value, thrownError, isStopped, _isComplete } = this; |
| 11 |
if (hasError) { |
| 12 |
subscriber.error(thrownError); |
| 13 |
} |
| 14 |
else if (isStopped || _isComplete) { |
| 15 |
_hasValue && subscriber.next(_value); |
| 16 |
subscriber.complete(); |
| 17 |
} |
| 18 |
} |
| 19 |
next(value) { |
| 20 |
if (!this.isStopped) { |
| 21 |
this._value = value; |
| 22 |
this._hasValue = true; |
| 23 |
} |
| 24 |
} |
| 25 |
complete() { |
| 26 |
const { _hasValue, _value, _isComplete } = this; |
| 27 |
if (!_isComplete) { |
| 28 |
this._isComplete = true; |
| 29 |
_hasValue && super.next(_value); |
| 30 |
super.complete(); |
| 31 |
} |
| 32 |
} |
| 33 |
} |
| 34 |
//# sourceMappingURL=AsyncSubject.js.map |