Skip to content

Commit 0e069bb

Browse files
committed
Update docs
1 parent f2de358 commit 0e069bb

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

packages/riverpod/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ TL;DR
1515

1616
- Added a test-only `ProviderContainer.test`.
1717
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.
1820

1921
### Depreciation notices
2022

packages/riverpod/lib/src/core/provider/notifier_provider.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ mixin AnyNotifier<StateT> {
5757
@protected
5858
Ref<StateT> get ref => $ref;
5959

60+
/// {@template riverpod.listen_self}
6061
/// Listens to changes on the value exposed by this provider.
6162
///
6263
/// The listener will be called immediately after the provider completes building.
@@ -66,6 +67,7 @@ mixin AnyNotifier<StateT> {
6667
/// and new value can potentially be identical.
6768
///
6869
/// Returns a function which can be called to remove the listener.
70+
/// {@endtemplate}
6971
@protected
7072
void Function() listenSelf(
7173
void Function(StateT? previous, StateT next) listener, {
@@ -167,7 +169,12 @@ abstract base class $ClassProvider< //
167169
}
168170

169171
/// {@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.
171178
/// {@endtemplate}
172179
Override overrideWithBuild(
173180
RunNotifierBuild<NotifierT, CreatedT> build,

packages/riverpod/lib/src/core/ref.dart

+1-7
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,7 @@ abstract class Ref<State extends Object?> {
8383
/// ```
8484
void notifyListeners();
8585

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}
9387
void Function() listenSelf(
9488
void Function(State? previous, State next) listener, {
9589
void Function(Object error, StackTrace stackTrace)? onError,

0 commit comments

Comments
 (0)