Skip to main content

fulfilledObservablePipe

Alternative: fulfilled$$$

Inlined: fulfilledObservable, fulfilled$$

Types

function fulfilledObservablePipe<GInNextValue, GOut>(
onFulfilled: IThenObservableOnFulfilled<GInNextValue, GOut>,
): IObservablePipe<IThenObservableInNotifications<GInNextValue>, IFulfilledObservableOutNotifications<GOut>>
export type IFulfilledObservableOutNotifications<GOut> =
GOut
| IErrorNotification;

Definition

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

It returns:

thenObservablePipe<GInNextValue, IFulfilledObservableOutNotifications<GOut>>(
onFulfilled,
throwError,
);

Example

Get the text content of the Response of an HTTP request

const subscribe = pipe$$(request$, [
fulfilled$$$((response: Response): IObservable<IFromPromiseObservableNotifications<string>> => {
if (response.ok) {
return fromPromise(response.text());
} else {
return throwError(createNetworkError());
}
}),
]);

subscribe((notification) => {
console.log(notification.name, notification.value);
});

Output (if request succeed):

'next', 'The following are the gr...'
'complete', undefined