Skip to main content

thenAnyObservablePipe

Alternative: thenAny$$$

Inlined: thenAnyObservable, thenAny$$

Types

function thenAnyObservablePipe<GInNextValue, GOut>(
onThenAny: IThenAnyObservableCallback<GInNextValue, GOut>,
): IObservablePipe<IThenObservableInNotifications<GInNextValue>, GOut>

Definition

This function is similar to the method .then of a Promise:

When a complete or error Notification is received, onThenAny is called with the resolved state.

Then, it emits the values from the Observable returned by onThenAny.

Example

When an HTTP request completes, emits its state

const subscribe = pipe$$(request$, [
thenAny$$$(({ state }): IObservable<IEmptyObservableNotifications> => {
return single(`state: ${state}`);
}),
]);

subscribe((value) => {
console.log(nvalue);
});

Output:

if fulfilled

'state fulfilled'

if rejected

'state rejected'