riverpod
riverpod copied to clipboard
2.0-dev "listenSelf" on StateNotifier should track the state not notifier
2.0.0-dev.4 introduces listenSelf
on providers. When used with a StateNotifierProvider
the arguments to the listenSelf
function are typed for the notifier and not the state. We were expecting that the listenSelf
would track state changes - especially since a likely pattern already provides access to the notifier.
final aProvider = StateNotifierProvider<ANotifier, AState>((ref) {
final aNotifier = ANotifier();
ref.listenSelf((ANotifier? previous, ANotifier notAState) {}); // <-- expecting this to track state, have the notifier in scope
return aNotifier;
});