File tree 3 files changed +11
-8
lines changed
3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 15
15
16
16
- Added a test-only ` ProviderContainer.test ` .
17
17
This automatically disposes the ` ProviderContainer ` after tests end.
18
+ - Added ` AnyNotifier ` , an interface that _ all_ Notifiers implement. This can be used to implement mixins.
19
+ - ` listenSelf ` now returns a way to close the subscription.
18
20
19
21
### Depreciation notices
20
22
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ mixin AnyNotifier<StateT> {
57
57
@protected
58
58
Ref <StateT > get ref => $ref;
59
59
60
+ /// {@template riverpod.listen_self}
60
61
/// Listens to changes on the value exposed by this provider.
61
62
///
62
63
/// The listener will be called immediately after the provider completes building.
@@ -66,6 +67,7 @@ mixin AnyNotifier<StateT> {
66
67
/// and new value can potentially be identical.
67
68
///
68
69
/// Returns a function which can be called to remove the listener.
70
+ /// {@endtemplate}
69
71
@protected
70
72
void Function () listenSelf (
71
73
void Function (StateT ? previous, StateT next) listener, {
@@ -167,7 +169,12 @@ abstract base class $ClassProvider< //
167
169
}
168
170
169
171
/// {@template riverpod.override_with_build}
170
- /// Hello world
172
+ /// Enables overriding the `build` method of a notifier.
173
+ ///
174
+ /// This overrides the `build` method of the notifier, without overriding
175
+ /// anything else in the notifier.
176
+ /// This is useful to mock the initialization logic of a notifier inside tests,
177
+ /// but to keep the rest of the notifier intact.
171
178
/// {@endtemplate}
172
179
Override overrideWithBuild (
173
180
RunNotifierBuild <NotifierT , CreatedT > build,
Original file line number Diff line number Diff line change @@ -83,13 +83,7 @@ abstract class Ref<State extends Object?> {
83
83
/// ```
84
84
void notifyListeners ();
85
85
86
- /// Listens to changes on the value exposed by this provider.
87
- ///
88
- /// The listener will be called immediately after the provider completes building.
89
- ///
90
- /// As opposed to [listen] , the listener will be called even if
91
- /// `updateShouldNotify` returns false, meaning that the previous
92
- /// and new value can potentially be identical.
86
+ /// {@macro riverpod.listen_self}
93
87
void Function () listenSelf (
94
88
void Function (State ? previous, State next) listener, {
95
89
void Function (Object error, StackTrace stackTrace)? onError,
You can’t perform that action at this time.
0 commit comments