frontend/.pnpm-store/v3/files/e7/8e838c6f5e4083d53a59c85ad755b9c9e7167bdad7f925dd86cc2c1c6fe4c817058481ccf000be5c17c50bd7fc16248a7197f405cf92424cfd5d33bb86fec8

41 lines
1.1 KiB
Plaintext

import { Subject } from './Subject';
import { Subscription } from './Subscription';
export class AsyncSubject extends Subject {
constructor() {
super(...arguments);
this.value = null;
this.hasNext = false;
this.hasCompleted = false;
}
_subscribe(subscriber) {
if (this.hasError) {
subscriber.error(this.thrownError);
return Subscription.EMPTY;
}
else if (this.hasCompleted && this.hasNext) {
subscriber.next(this.value);
subscriber.complete();
return Subscription.EMPTY;
}
return super._subscribe(subscriber);
}
next(value) {
if (!this.hasCompleted) {
this.value = value;
this.hasNext = true;
}
}
error(error) {
if (!this.hasCompleted) {
super.error(error);
}
}
complete() {
this.hasCompleted = true;
if (this.hasNext) {
super.next(this.value);
}
super.complete();
}
}
//# sourceMappingURL=AsyncSubject.js.map