onSend<T> method
Wait for a channel send operation to complete.
Races a send operation on a channel sender. Use this when you need to coordinate sending with other async operations or implement backpressure.
Parameters:
sender
: Sender to use for the send operationvalue
: Value to sendbody
: Function to call when send completestag
: Optional tag for debuggingif_
: Optional guard condition
Example:
// Producer with flow control
await XSelect.run<String>((s) => s
..onRecvValue(controlChannel, (cmd) => 'Command: $cmd')
..onSend(outputChannel, processedData, () => 'Data sent')
..onTimeout(Duration(seconds: 10), () => 'Send timeout')
);
Implementation
SelectBuilder<R> onSend<T>(
Sender<T> sender, T value, FutureOr<R> Function() body,
{Object? tag, bool Function()? if_}) {
return onFuture(sender.send(value), (_) => body(), tag: tag, if_: if_);
}