onStateChange property
override
Emits the new NodeState whenever the node's lifecycle state changes.
Consecutive duplicates are filtered except for NodeState.needsLogin.
A re-auth attempt can produce another needsLogin with a fresh auth URL;
callers commonly respond to the state event by calling status, so those
repeats remain observable.
Implementation
@override
Stream<NodeState> get onStateChange => Stream<NodeState>.multi((controller) {
NodeState? last;
final subscription = _stateController.stream.listen(
(state) {
if (state == last && state != NodeState.needsLogin) return;
last = state;
controller.add(state);
},
onError: controller.addError,
onDone: controller.close,
);
controller.onCancel = subscription.cancel;
}, isBroadcast: true);