Represents a push-based event or value that an Observable can emit.
This class is particularly useful for operators that manage notifications,
like materialize , dematerialize , observeOn , and
others. Besides wrapping the actual delivered value, it also annotates it
with metadata of, for instance, what type of push message it is (next,
error, or complete).
Static Methods
createNext()
A shortcut to create a Notification instance of the type next from a
given value.
static createNext<T>(value: T): Notification<T>
Parameters
Returns
Notification<T>: The "next" Notification representing the
argument.
createError()
A shortcut to create a Notification instance of the type error from a
given error.
static createError<T>(err?: any): Notification<T>
Parameters
err
Optional. Default is undefined.
The error error.
Returns
Notification<T>: The "error" Notification representing the
argument.
createComplete()
A shortcut to create a Notification instance of the type complete.
static createComplete(): Notification<any>
Parameters
There are no parameters.
Returns
Notification<any>: The valueless "complete" Notification.
Constructor
constructor(kind: NotificationKind, value?: T, error?: any)
Parameters
kind
Type: NotificationKind.
value
Optional. Default is undefined.
Type: T.
error
Optional. Default is undefined.
Type: any.
Properties
Property Type Description
hasValue
boolean
kind
NotificationKind
Declared in constructor.
value
T
Declared in constructor.
error
any
Declared in constructor.
Methods
observe()
Delivers to the given observer the value wrapped by this Notification.
observe(observer: PartialObserver<T>): any
Parameters
observer
Type: PartialObserver.
Returns
any:
do()
Given some Observer callbacks, deliver the value represented by the
current Notification to the correctly corresponding callback.
do(next: (value: T) => void, error?: (err: any) => void, complete?: () => void): any
Parameters
next
An Observer next callback.
error
Optional. Default is undefined.
An Observer error callback.
complete
Optional. Default is undefined.
An Observer complete callback.
Returns
any:
accept()
Takes an Observer or its individual callback functions, and calls observe
or do methods accordingly.
accept(nextOrObserver: PartialObserver<T> | ((value: T) => void), error?: (err: any) => void, complete?: () => void)
Parameters
nextOrObserver
An Observer or
the next callback.
error
Optional. Default is undefined.
An Observer error callback.
complete
Optional. Default is undefined.
An Observer complete callback.
toObservable()
Returns a simple Observable that just delivers the notification represented
by this Notification instance.
toObservable(): Observable<T>
Parameters
There are no parameters.
Returns
Observable<T>: