import { Subject } from './Subject'; import { Subscriber } from './Subscriber'; import { Subscription } from './Subscription'; /** * A variant of Subject that only emits a value when it completes. It will emit * its latest value to all its observers on completion. * * @class AsyncSubject<T> */ export class AsyncSubject<T> extends Subject<T> { private value: T = null; private hasNext: boolean = false; private hasCompleted: boolean = false; /** @deprecated This is an internal implementation detail, do not use. */ _subscribe(subscriber: Subscriber<any>): Subscription { 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: T): void { if (!this.hasCompleted) { this.value = value; this.hasNext = true; } } error(error: any): void { if (!this.hasCompleted) { super.error(error); } } complete(): void { this.hasCompleted = true; if (this.hasNext) { super.next(this.value); } super.complete(); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
observable | Folder | 0755 |
|
|
operators | Folder | 0755 |
|
|
scheduled | Folder | 0755 |
|
|
scheduler | Folder | 0755 |
|
|
symbol | Folder | 0755 |
|
|
testing | Folder | 0755 |
|
|
util | Folder | 0755 |
|
|
AsyncSubject.ts | File | 1.21 KB | 0644 |
|
BehaviorSubject.ts | File | 1.13 KB | 0644 |
|
InnerSubscriber.ts | File | 732 B | 0644 |
|
Notification.ts | File | 4.81 KB | 0644 |
|
Observable.ts | File | 15.79 KB | 0644 |
|
Observer.ts | File | 410 B | 0644 |
|
Operator.ts | File | 184 B | 0644 |
|
OuterSubscriber.ts | File | 646 B | 0644 |
|
ReplaySubject.ts | File | 4.18 KB | 0644 |
|
Rx.ts | File | 9.46 KB | 0644 |
|
Scheduler.ts | File | 2.48 KB | 0644 |
|
Subject.ts | File | 4.81 KB | 0644 |
|
SubjectSubscription.ts | File | 846 B | 0644 |
|
Subscriber.ts | File | 9.23 KB | 0644 |
|
Subscription.ts | File | 7.88 KB | 0644 |
|
config.ts | File | 1.4 KB | 0644 |
|
innerSubscribe.ts | File | 3.18 KB | 0644 |
|
types.ts | File | 3.05 KB | 0644 |
|
umd.ts | File | 598 B | 0644 |
|