Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc/improve readme file #21

Merged
merged 3 commits into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 💻

Expand All @@ -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
Expand Down
Loading