Josep M Sobrepere 75ba112753 feat(utils): startWith -> defaultStart on suspense utils
BREAKING CHANGE: suspend, suspended and switchMapSuspended will only
emit SUSPENSE if the source doesn't emit synchronously
2020-10-02 20:50:01 +02:00

14 lines
456 B
TypeScript

import { ObservableInput, from, Observable } from "rxjs"
import { SUSPENSE } from "@react-rxjs/core"
import { defaultStart } from "./internal-utils"
/**
* A RxJS creation operator that prepends a SUSPENSE on the source observable.
*
* @param source$ Source observable
*/
export const suspend: <T>(
source$: ObservableInput<T>,
) => Observable<T | typeof SUSPENSE> = <T>(source$: ObservableInput<T>) =>
defaultStart(SUSPENSE)(from(source$)) as any