Skip to content

API Documentation / @pinia/colada / StreamedMutationOptions_WithReducer

Interface: StreamedMutationOptions_WithReducer<TChunk, TData, TVars> ​

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

Extends ​

Type Parameters ​

TChunk ​

TChunk

TData ​

TData

TVars ​

TVars

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.

Parameters ​

data ​

TData

chunk ​

TChunk

Returns ​

TData


stream ​

ts
stream: (vars, 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 mutation data as soon as it arrives. Pass the signal to your requests to stop the stream when the mutation is cancelled.

Parameters ​

vars ​

TVars

context ​

StreamedMutationFnContext

Returns ​

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

Inherited from ​

StreamedMutationOptions_Base.stream

Released under the MIT License.