batchIntentsDecorator

fun <S : MVIState, I : MVIIntent, A : MVIAction> batchIntentsDecorator(mode: BatchingMode, queue: BatchQueue<I> = BatchQueue(), name: String? = "BatchIntentsDecorator", onUnhandledIntent: suspend PipelineContext<S, I, A>.(intent: I) -> Unit = {}): PluginDecorator<S, I, A>

A decorator that batches intents based on the BatchingMode and stores them in a BatchQueue.

Based on the mode, the intents will be batched either by time ("flush every N seconds") or amount. See BatchingMode for details.

Parameters

onUnhandledIntent

invoked for every intent that the child plugin returns instead of consuming. In BatchingMode.Amount the callback fires for each unhandled item in the batch and the last one is also returned from the decorator so the store can continue its regular undelivered flow. In BatchingMode.Time flushing happens on a background job, therefore every unhandled item is forwarded to this callback immediately and nothing is bubbled up. By default the callback is a no-op, preserving the previous behaviour where unhandled intents were dropped.