class
stable
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
).
class Notification<T> { static createNext<T>(value: T): Notification<T> static createError<T>(err?: any): Notification<T> static createComplete(): Notification<any> constructor(kind: 'N' | 'E' | 'C', value?: T, error?: any) hasValue: boolean kind: 'N' | 'E' | 'C' value?: T error?: any observe(observer: PartialObserver<T>): any do(next: (value: T) => void, error?: (err: any) => void, complete?: () => void): any accept(nextOrObserver: PartialObserver<T> | ((value: T) => void), error?: (err: any) => void, complete?: () => void) toObservable(): Observable<T> }
A shortcut to create a Notification instance of the type next
from a given value.
static createNext<T>(value: T): Notification<T>
value | The |
Notification<T>
: The "next" Notification representing the argument.
A shortcut to create a Notification instance of the type error
from a given error.
static createError<T>(err?: any): Notification<T>
err | Optional. Default is The |
Notification<T>
: The "error" Notification representing the argument.
A shortcut to create a Notification instance of the type complete
.
static createComplete(): Notification<any>
There are no parameters.
Notification<any>
: The valueless "complete" Notification.
constructor(kind: 'N' | 'E' | 'C', value?: T, error?: any)
kind | Type: |
value | Optional. Default is Type: |
error | Optional. Default is Type: |
Property | Type | Description |
---|---|---|
hasValue | boolean | |
kind | 'N' | 'E' | 'C' | Declared in constructor. |
value | T | Declared in constructor. |
error | any | Declared in constructor. |
observe(observer: PartialObserver<T>): any
Delivers to the given observer
the value wrapped by this Notification.
observer | Type: |
any
:
do(next: (value: T) => void, error?: (err: any) => void, complete?: () => void): any
Given some Observer
callbacks, deliver the value represented by the current Notification to the correctly corresponding callback.
next | An Observer |
error | Optional. Default is An Observer |
complete | Optional. Default is An Observer |
any
:
accept(nextOrObserver: PartialObserver<T> | ((value: T) => void), error?: (err: any) => void, complete?: () => void)
Takes an Observer or its individual callback functions, and calls observe
or do
methods accordingly.
nextOrObserver | An Observer or the |
error | Optional. Default is An Observer |
complete | Optional. Default is An Observer |
toObservable(): Observable<T>
Returns a simple Observable that just delivers the notification represented by this Notification instance.
There are no parameters.
Observable<T>
:
© 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/Notification