OneShotSender<T> class final

Promise-like sender for one-shot channels.

Can send exactly one value, after which the channel becomes unavailable for further sends. Perfect for promise resolution patterns.

Characteristics:

  • Single-send: Only one send call succeeds
  • Direct delivery: Value delivered to waiting receivers
  • Auto-disconnect: Channel disconnects after successful send
  • Type-safe: Compile-time guarantees about value delivery

Example:

final (promiseTx, promiseRx) = OneShot.channel<Result>();

// Promise resolution
Future<void> resolvePromise() async {
  final result = await computeExpensiveResult();

  // This succeeds
  final sendResult = await promiseTx.send(result);
  assert(sendResult is SendOk);

  // This fails - already sent
  final secondSend = promiseTx.trySend(anotherResult);
  assert(secondSend is SendErrorDisconnected);
}
Available extensions

Properties

hashCode int
The hash code for this object.
no setterinherited
isDisconnected bool
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send(T value) Future<SendResult>
sendAll(Iterable<T> it) Future<void>

Available on Sender<T>, provided by the SenderBatchX extension

Send all items with backpressure handling.
sendTimeout(T v, Duration d) Future<SendResult>

Available on Sender<T>, provided by the SenderTimeoutX extension

Send a value with a timeout to prevent indefinite blocking.
toString() String
A string representation of this object.
inherited
trySend(T value) SendResult
trySendAll(Iterable<T> it) Future<void>

Available on Sender<T>, provided by the SenderBatchX extension

Send all items using trySend without waiting (best-effort).

Operators

operator ==(Object other) bool
The equality operator.
inherited