class
stable
A Subject is a special type of Observable that allows values to be multicasted to many Observers. Subjects are like EventEmitters.
class Subject<T> extends Observable implements SubscriptionLike { static create: Function constructor() observers: Observer<T>[] closed: false isStopped: false hasError: false thrownError: any lift<R>(operator: Operator<T, R>): Observable<R> next(value?: T) error(err: any) complete() unsubscribe() _trySubscribe(subscriber: Subscriber<T>): TeardownLogic _subscribe(subscriber: Subscriber<T>): Subscription asObservable(): Observable<T> // inherited from index/Observable static create: Function static if: typeof iif static throw: typeof throwError constructor(subscribe?: (this: Observable<T>, subscriber: Subscriber<T>) => TeardownLogic) _isScalar: boolean source: Observable<any> operator: Operator<any, T> lift<R>(operator: Operator<T, R>): Observable<R> subscribe(observerOrNext?: PartialObserver<T> | ((value: T) => void), error?: (error: any) => void, complete?: () => void): Subscription _trySubscribe(sink: Subscriber<T>): TeardownLogic forEach(next: (value: T) => void, promiseCtor?: PromiseConstructorLike): Promise<void> pipe(...operations: OperatorFunction<any, any>[]): Observable<any> toPromise(promiseCtor?: PromiseConstructorLike): Promise<T> }
BehaviorSubject
ReplaySubject
AsyncSubject
Every Subject is an Observable and an Observer. You can subscribe to a Subject, and you can call next to feed values as well as error and complete.
Property | Type | Description |
---|---|---|
create | Function |
constructor()
There are no parameters.
Property | Type | Description |
---|---|---|
observers | Observer<T>[] | |
closed | false | |
isStopped | false | |
hasError | false | |
thrownError | any |
lift<R>(operator: Operator<T, R>): Observable<R>
operator | Type: |
Observable<R>
next(value?: T)
value | Optional. Default is Type: |
error(err: any)
err | Type: |
complete()
There are no parameters.
unsubscribe()
There are no parameters.
_trySubscribe(subscriber: Subscriber<T>): TeardownLogic
subscriber | Type: |
TeardownLogic
_subscribe(subscriber: Subscriber<T>): Subscription
subscriber | Type: |
Subscription
asObservable(): Observable<T>
Creates a new Observable with this Subject as the source. You can do this to create customize Observer-side logic of the Subject and conceal it from code that uses the Observable.
There are no parameters.
Observable<T>
: Observable that the Subject casts to
© 2015–2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/index/class/Subject