import { ObservableInput, OperatorFunction, ObservedValueOf, pipe } from "rxjs" import { switchMap } from "rxjs/operators" import { suspend } from "./suspend" import { SUSPENSE } from "@react-rxjs/core" /** * Same behaviour as rxjs' `switchMap`, but prepending every new event with * SUSPENSE. * * @param fn Projection function */ export const switchMapSuspended = >( project: (value: T, index: number) => O, ): OperatorFunction | typeof SUSPENSE> => pipe(switchMap((x, index) => suspend(project(x, index))))