UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

23 lines 1.19 kB
import type { StreamSource } from "./types.mjs"; /** A snapshot emitted by {@link streamChunks} after each chunk lands. */ export interface ChunkSnapshot<P> { /** All chunks loaded so far, in order. */ chunks: P[]; /** `true` on the snapshot that completes the stream (last-chunk signal). */ lastChunk: boolean; } /** * Drive any {@link StreamSource} `mode` and yield an accumulating snapshot after * each chunk lands. Isomorphic: the client (`useStream`) iterates it and * `setState`s each snapshot for progressive reveal; the server awaits it to * completion for non-incremental modes. * * - `'data'` - one `load`, one terminal snapshot. * - `'urls'` - `loadUrls`, then `loadChunk` per URL, one snapshot each; the * final URL is the last chunk unless `loadUrls` returned `lastChunk: false`. * - `'stream'` - runs the generator (which pushes into the array and yields), * surfacing a snapshot per yield, then a terminal snapshot on return. * * Stops early (without a terminal snapshot) if `signal` aborts. */ export declare function streamChunks<P, O>(source: StreamSource<P, O>, options: O, signal: AbortSignal): AsyncGenerator<ChunkSnapshot<P>, void, void>;