Notify class
A lightweight synchronization primitive for control-plane signaling.
Notify is perfect for coordination without data payloads. Unlike channels, it doesn't carry values - just wake-up signals. Use it for configuration changes, shutdown notifications, flush commands, and "check your state" signals.
Key Concepts
- Permits: Stored notifications that can be consumed immediately
- Waiters: Tasks waiting for notifications
- notifyOne: Wake one waiter or store one permit
- notifyAll: Wake all current waiters (doesn't store permits)
Usage Patterns
{@tool snippet example/notify_example.dart} {@end-tool}
When to use Notify vs Channels
- Use Notify for: Config changes, shutdown signals, flush commands, "wake up and check" notifications
- Use Channels for: Data processing, task queues, request/reply, anything with payloads
Constructors
- Notify()
Properties
- epoch → int
-
Debug counter that increments on each notification (for testing/debugging).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisconnected → bool
-
trueif this Notify has been closed and will reject new waiters.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → void - Close this Notify and fail all current and future waiters.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notified(
) → (Future< void> , void Function()) - Register to be notified, returning a future and cancellation function.
-
notifiedTimeout(
Duration d) → Future< void> -
notifyAll(
) → void - Wake up all currently waiting tasks (does not store permits).
-
notifyN(
int n) → void -
notifyOne(
) → void - Wake up exactly one waiter, or store one permit if no waiters.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited