A Subject is a special type of Observable that allows values to be
multicasted to many Observers. Subjects are like EventEmitters.
Description
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.
Static Properties
Property Type Description
create
Function
Constructor
constructor()
Parameters
There are no parameters.
Properties
Property Type Description
observers
Observer<T>[]
closed
false
isStopped
false
hasError
false
thrownError
any
Methods
lift()
lift<R>(operator: Operator<T, R>): Observable<R>
Parameters
Returns
Observable<R>
next()
next(value?: T)
Parameters
value
Optional. Default is undefined
.
Type: T
.
error()
error(err: any)
Parameters
complete()
complete()
Parameters
There are no parameters.
unsubscribe()
unsubscribe()
Parameters
There are no parameters.
_trySubscribe()
_trySubscribe(subscriber: Subscriber<T>): TeardownLogic
Parameters
subscriber
Type: Subscriber
.
Returns
TeardownLogic
_subscribe()
_subscribe(subscriber: Subscriber<T>): Subscription
Parameters
subscriber
Type: Subscriber
.
Returns
Subscription
asObservable()
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.
asObservable(): Observable<T>
Parameters
There are no parameters.
Returns
Observable<T>
: Observable that the Subject casts to