Like switchMap, but applying a startWith(SUSPENSE) to the inner Observable.

function switchMapSuspended<T, O extends ObservableInput<any>>(project: (value: T, index: number) => O):
OperatorFunction<T, ObservedValueOf<O> | typeof SUSPENSE>;


  • project: A function that, when applied to an item emitted by the source Observable, returns an Observable.


OperatorFunction<T, ObservedValueOf<O> | typeof SUSPENSE>: An Observable that emits the result of applying the projection function to each item emitted by the source Observable, and taking only the values from the most recently projected inner Observable, prepended with SUSPENSE.


import { switchMapSuspended } from '@react-rxjs/utils'
const story$ = selectedStoryId$.pipe(switchMapSuspended(getStory$))

See also