API Documentation / @pinia/colada / StreamedQueryOptions_WithReducer
Interface: StreamedQueryOptions_WithReducer<TChunk, TData>
Options for streamedQuery that merge the chunks with a custom reducer.
Extends
StreamedQueryOptions_Base<TChunk>
Type Parameters
TChunk
TChunk
TData
TData
Properties
initialValue
initialValue: TData;Data used before the first chunk arrives.
reducer
reducer: (data, chunk) => TData;Merges a new chunk into the accumulated data. Must not mutate data. If it returns undefined, the next chunk starts from initialValue.
Parameters
data
TData
chunk
TChunk
Returns
TData
refetchMode?
refetchMode?: StreamedQueryRefetchMode;What to do with the existing data when the query is fetched again.
Default
'reset'See
Inherited from
StreamedQueryOptions_Base.refetchMode
stream
stream: (context) =>
| AsyncIterable<TChunk, any, any>
| Promise<AsyncIterable<TChunk, any, any>>;Function that returns an AsyncIterable (e.g. an async generator). Each chunk is added to the query data as soon as it arrives. Pass the signal to your requests to stop the stream when the query is cancelled.
Parameters
context
Returns
| AsyncIterable<TChunk, any, any> | Promise<AsyncIterable<TChunk, any, any>>