onNotifyOnce method
Adds a branch that listens to Notify but only once in the lifetime of this builder instance (useful for one-shot shutdown signals).
Note: since XSelect.run
is single-shot, “once” here simply gates
arming when you re-create the builder in a loop; after the first trigger,
the arm won’t be armed again (until you reset your own flag).
See also:
- onNotify - Parent
Implementation
SelectBuilder<R> onNotifyOnce(
Notify notify,
FutureOr<R> Function() action, {
Object? tag,
bool Function()? if_,
}) {
var consumed = false;
return onNotify(
notify,
() {
// Mark consumed on first trigger.
consumed = true;
return action();
},
tag: tag,
if_: () {
if (consumed) return false; // do not arm again
return if_ == null ? true : if_();
},
);
}