Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / react/src/public-api / useSuspense

Function: useSuspense() ​

useSuspense<T>(source): T

Defined in: projects/libraries/streamix/react/src/lib/suspense.ts:86

Suspends until source emits for the first time, then returns its live value and stays reactive to later emissions — folding suspense and useIterable into a single hook, so you don't need to wire the two together by hand.

tsx
function Profile({ source }: { source: Atom<Profile> }) {
  const profile = useSuspense(source); // suspends, then stays live
  return <span>{profile.name}</span>;
}

Type Parameters ​

T ​

T

Parameters ​

source ​

Atom<T>

Returns ​

T

Released under the MIT License.