Skip to content

Commit

Permalink
doc(auto_refresh): fix codegen syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
giboin committed Jul 4, 2024
1 parent 4a8c2d0 commit ff7801e
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions lib/src/auto_refresh_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension AutoRefreshExtension<T> on AutoDisposeRef<T> {
///
/// without codegen:
/// ```dart
/// final myProvider = Provider<int>((ref) {
/// final dataProvider = Provider<int>((ref) {
/// ref.autoRefresh(const Duration(seconds: 1));
/// return fetchData();
/// });
Expand All @@ -25,7 +25,7 @@ extension AutoRefreshExtension<T> on AutoDisposeRef<T> {
/// with codegen:
/// ```dart
/// @riverpod
/// int myProvider(MyRef ref) {
/// int data(DataRef ref) {
/// ref.autoRefresh(const Duration(seconds: 1));
/// return fetchData();
/// }
Expand All @@ -37,6 +37,24 @@ extension AutoRefreshExtension<T> on AutoDisposeRef<T> {

/// Refreshes the value each time the app returns to foreground.
///
/// Example usages:
/// without codegen:
/// ```dart
/// final dataProvider = Provider<int>((ref) {
/// ref.refreshWhenReturningToForeground();
/// return fetchData();
/// });
/// ```
///
/// with codegen:
/// ```dart
/// @riverpod
/// int data(DataRef ref) {
/// ref.refreshWhenReturningToForeground();
/// return fetchData();
/// }
/// ```
///
void refreshWhenReturningToForeground() {
final listener = AppLifecycleListener(onResume: invalidateSelf);
onDispose(listener.dispose);
Expand Down

0 comments on commit ff7801e

Please sign in to comment.