Skip to content

API Documentation / @pinia/colada / StreamedQueryOptions_WithReducer

Interface: StreamedQueryOptions_WithReducer<TChunk, TData> ​

Options for streamedQuery that merge the chunks with a custom reducer.

Extends ​

Type Parameters ​

TChunk ​

TChunk

TData ​

TData

Properties ​

initialValue ​

ts
initialValue: TData;

Data used before the first chunk arrives.


reducer ​

ts
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? ​

ts
refetchMode?: StreamedQueryRefetchMode;

What to do with the existing data when the query is fetched again.

Default ​

ts
'reset'

See ​

StreamedQueryRefetchMode

Inherited from ​

StreamedQueryOptions_Base.refetchMode


stream ​

ts
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 ​

StreamedQueryFnContext

Returns ​

| AsyncIterable<TChunk, any, any> | Promise<AsyncIterable<TChunk, any, any>>

Inherited from ​

StreamedQueryOptions_Base.stream

Released under the MIT License.