OneShotReceiver<T> class
final
Promise-like receiver for one-shot channels.
Receives exactly one value based on the channel's consumption mode. Provides promise-like waiting semantics with explicit result types.
Consumption modes:
- consumeOnce: true: First recv() gets value, subsequent calls get disconnected
- consumeOnce: false: All recv() calls get the same value
Example - Single consumption:
final (tx, rx) = OneShot.channel<String>(consumeOnce: true);
await tx.send('hello');
final result1 = await rx.recv(); // Gets 'hello'
final result2 = await rx.recv(); // Gets RecvErrorDisconnected
Example - Multiple consumption:
final (tx, rx) = OneShot.channel<Config>(consumeOnce: false);
await tx.send(config);
final config1 = await rx.recv(); // Gets config
final config2 = await rx.recv(); // Gets same config
- 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
-
recv(
) → Future< RecvResult< T> > -
recvAll(
{Duration idle = Duration.zero, int? max}) → Future< Iterable< T> > -
Available on Receiver<
Receive multiple values with batching and idle timeout.T> , provided by the ReceiverDrainX extension -
recvCancelable(
) → (Future< RecvResult< , void Function())T> > -
recvTimeout(
Duration d) → Future< RecvResult< T> > -
Available on Receiver<
Receive a value with a timeout to prevent indefinite waiting.T> , provided by the ReceiverTimeoutX extension -
toString(
) → String -
A string representation of this object.
inherited
-
tryRecv(
) → RecvResult< T> -
tryRecvAll(
{int? max}) → Iterable< T> -
Available on Receiver<
Drain all immediately available values without waiting.T> , provided by the ReceiverDrainX extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited