Skip to main content
Module

x/rxjs/mod.ts>Notification

Deno port of RXJS
Latest
class Notification
Deprecated
Deprecated

It is NOT recommended to create instances of Notification directly. Rather, try to create POJOs matching the signature outlined in ObservableNotification. For example: { kind: 'N', value: 1 }, { kind: 'E', error: new Error('bad') }, or { kind: 'C' }. Will be removed in v8.

import { Notification } from "https://deno.land/x/rxjs@v1.0.2/mod.ts";

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).

Constructors

new
Notification(kind: "N", value?: T)

Creates a "Next" notification object.

new
Notification(
kind: "E",
value: undefined,
error: any,
)

Creates an "Error" notification object.

new
Notification(kind: "C")

Creates a "completion" notification object.

new
Notification(
kind: "N" | "E" | "C",
value?: T,
error?: any,
)

Properties

readonly
deprecated
hasValue: boolean

A value signifying that the notification will "next" if observed. In truth, This is really synonymous with just checking kind === "N".

Methods

deprecated
accept(
next: (value: T) => void,
error: (err: any) => void,
complete: () => void,
): void

Executes a notification on the appropriate handler from a list provided. If a handler is missing for the kind of notification, nothing is called and no error is thrown, it will be a noop.

deprecated
accept(next: (value: T) => void, error: (err: any) => void): void

Executes a notification on the appropriate handler from a list provided. If a handler is missing for the kind of notification, nothing is called and no error is thrown, it will be a noop.

deprecated
accept(next: (value: T) => void): void

Executes the next handler if the Notification is of kind "N". Otherwise this will not error, and it will be a noop.

deprecated
accept(observer: PartialObserver<T>): void

Executes the appropriate handler on a passed observer given the kind of notification. If the handler is missing it will do nothing. Even if the notification is an error, if there is no error handler on the observer, an error will not be thrown, it will noop.

deprecated
do(
next: (value: T) => void,
error: (err: any) => void,
complete: () => void,
): void

Executes a notification on the appropriate handler from a list provided. If a handler is missing for the kind of notification, nothing is called and no error is thrown, it will be a noop.

deprecated
do(next: (value: T) => void, error: (err: any) => void): void

Executes a notification on the appropriate handler from a list provided. If a handler is missing for the kind of notification, nothing is called and no error is thrown, it will be a noop.

deprecated
do(next: (value: T) => void): void

Executes the next handler if the Notification is of kind "N". Otherwise this will not error, and it will be a noop.

observe(observer: PartialObserver<T>): void

Executes the appropriate handler on a passed observer given the kind of notification. If the handler is missing it will do nothing. Even if the notification is an error, if there is no error handler on the observer, an error will not be thrown, it will noop.

deprecated
toObservable(): Observable<T>

Returns a simple Observable that just delivers the notification represented by this Notification instance.

Static Properties

private
completeNotification

Static Methods

A shortcut to create a Notification instance of the type complete.

deprecated
createError(err?: any)

A shortcut to create a Notification instance of the type error from a given error.

deprecated
createNext<T>(value: T)

A shortcut to create a Notification instance of the type next from a given value.