suspend(observable)

A RxJS creation operator that prepends a SUSPENSE to the source Observable.

function suspend<T>(source$: Observable<T>) => Observable<T | typeof SUSPENSE>

Arguments

  • source$: The source Observable.

Returns

Observable<T | typeof SUSPENSE>: An Observable that emits SUSPENSE as its first value, followed by the values from the source Observable.

Example

import { switchMap } from 'rxjs/operators'
import { suspend } from '@react-rxjs/utils'
const story$ = selectedStoryId$.pipe(
switchMap(id => suspend(getStory$(id))
)

See also