-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from bamlab/doc/improve-readme-file
Doc/improve readme file
- Loading branch information
Showing
1 changed file
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,21 @@ | |
[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason) | ||
[![License: MIT][license_badge]][license_link] | ||
|
||
Community extensions for Riverpods | ||
Useful extensions on ref types for Riverpod. | ||
|
||
Ref types are the way to interact with providers in Riverpod. They are built to be composable and flexible. This package provides some useful extensions on ref types to make them even more powerful and easily add common functionalities on your providers, such as auto-refreshing for example. | ||
|
||
## Features 🚀 | ||
|
||
This package adds the following methods to ref types: | ||
|
||
- `cacheFor` on `AutoDisposeRef` - Prevents the provider from being disposed for the specified duration. | ||
|
||
- `cacheDataFor` on `AutoDisposeFutureProviderRef` - Keeps the data of the future provider for the specified duration. | ||
|
||
- `debounce` on `AutoDisposeFutureProviderRef` - Wait for a specified duration before calling the provider's computation, and cancel the previous call if a new one is made. | ||
|
||
- `refreshWhenNetworkAvailable` on `AutoDisposeFutureProviderRef` - Automatically refresh the provider when the network is available. Uses the package [connectivity_plus](https://pub.dev/packages/connectivity_plus). | ||
|
||
## Installation 💻 | ||
|
||
|
@@ -16,8 +30,53 @@ Install via `dart pub add`: | |
dart pub add riverpods_community_extensions | ||
``` | ||
|
||
## Usage 🎨 | ||
|
||
Simply import the package and use the provided extensions on your ref types. | ||
|
||
Example without codegen: | ||
|
||
```dart | ||
import 'package:riverpods_community_extensions/riverpods_community_extensions.dart'; | ||
import 'package:riverpod/riverpod.dart'; | ||
final dataProvider = FutureProvider.autoDispose((ref) async { | ||
ref.cacheDataFor(const Duration(minutes: 5)); | ||
return fetchData(); | ||
}); | ||
``` | ||
|
||
Example with codegen: | ||
|
||
```dart | ||
import 'package:riverpods_community_extensions/riverpods_community_extensions.dart'; | ||
import 'package:riverpod/riverpod.dart'; | ||
part 'data_provider.g.dart'; | ||
@riverpod | ||
Future<int> data((ref) async { | ||
ref.cacheDataFor(const Duration(minutes: 5)); | ||
return fetchData(); | ||
}); | ||
``` | ||
|
||
--- | ||
|
||
## 👉 About Theodo apps | ||
|
||
We are a 100 people company of the [Theodo group](https://www.theodo.fr/), developing and designing multiplatform applications with [React Native](https://www.bam.tech/expertise/react-native) and [Flutter](https://www.bam.tech/expertise/flutter) using the Lean & Agile methodology. To get more information on the solutions that would suit your needs, feel free to get in touch by [email](mailto:[email protected]) or through or [contact form](https://www.bam.tech/contact)! | ||
|
||
We will always answer you with pleasure 😁 | ||
|
||
--- | ||
|
||
## Contributing 🤝 | ||
|
||
If you want to contribute to this project, please read the [CONTRIBUTE.md](CONTRIBUTE.md) file. | ||
|
||
[dart_install_link]: https://dart.dev/get-dart | ||
[github_actions_link]: https://docs.github.com/en/actions/learn-github-actions | ||
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg | ||
|