@_spi(Unknown)
class CommandBatcher
A class that batches commands and sends them. It serves as both a proxy and a transaction holder.
The API exposed by this class is experimental and is subject to change.
-
Adds a batchable command with a void response type to the current batch.
Declaration
Swift
@_spi(Unknown) @discardableResult func add(_ batchable: BatchableCommand<Void>) -> CommandBatcher.ResultProvider<Void>
Parameters
batchable
The batchable command to add.
Return Value
A ResultProvider that can be used to get the result of the command.
-
This adds a batchable command to the current batch. It should only be called from the closure passed to sendBatched.
Parameters:
- batchable: The batchable command to add.
Returns:
- A ResultProvider that can be used to get the result of the command. The result is guaranteed to be available after this async function completes.
Declaration
Swift
@_spi(Unknown) func add<T>(_ batchable: BatchableCommand<T>) -> CommandBatcher.ResultProvider<T> where T : CommandResponse
Parameters
batchable
The batchable command to add.
-
Errors that can be thrown by the command batcher.
Declaration
Swift
@_spi(Unknown) enum CommandBatcherError
extension CommandBatcher.CommandBatcherError : Equatable, Error, Hashable, Sendable
-
A structure that offers the ability to get the result of a command, once the batch request completes. It captures the result state, the response index and the ability to transform the result into a strongly typed response.
Declaration
Swift
@_spi(Unknown) struct ResultProvider<ResponseType> where ResponseType : Sendable
extension CommandBatcher.ResultProvider : Sendable