Comments (12)
I'll go for StateNotifierProvider.autoDispose.family(...)
.
This avoids a name clash with variables named provider
, and is more natural for people migrating from provider
It'll then be accompanied by:
.retry
, as per #42- (maybe)
.restorable
, for state restoration:final model = StateNotifierProvider.future.restorable( (ref) async { final json = await ref.restore(); final initialState = json == null ? null : MyModel.fromJson(json); return MyNotifier(initialState: initialState); }, name: 'model', serialize: (state) => state.toJson(), );
from riverpod.
I agree with the proposal.
I think that having too many different class names can be confusing for people trying out the package.
I also agree that keeping some of the providers with the original name can be helpful for people used to the well known Providers in the provider
package.
from riverpod.
I've just realised that we can't implement Provider.changeNotifier(...)
as ChangeNotifier
is Flutter-only, and extensions do not allow adding static members.
So this reinforces the idea of keeping StateNotifierProvider
& co, and apply this logic only to AutoDispose
, Family
and a potential Retry
.
from riverpod.
Another alternative is to do like @smiLLe suggested and go for final foo = provider.autoDispose(...)
instead of final foo = Provider.autoDispose(...)
.
This will allow using extensions to add custom members. And to begin with, we don't care about const constructors, so this using a function over a constructor doesn't matter.
from riverpod.
Logging in implemented directly on ProviderScope
ProviderScope(
observers: [
LoggerObserver(),
],
child: MyApp(),
);
class LoggerObserver extends ProviderStateOwnerObserver {
...
}
Although maybe we could have an "onChange" on providers individually
from riverpod.
I do. Finding Recoil made me rename Family
. Originally the pattern was called "ParametrizedProvider", which just sounds bad
Anyway, we'll see later. I'll focus on retry/restorable. There's a bunch of work to do on for the provider code-generator
from riverpod.
For my current project I started to do
final myProvider = createProvider.stateNotifier.family<T, Fam>((r, f) => .. );
by just using callable classes :)
from riverpod.
Personally i would prefer Retry over anything else :P
from riverpod.
I like how composable the modifier idea is. It allows implementing commonly wanted features almost without doing anything.
Do you have any modifiers in mind that I haven't mentioned yet?
Currently we'd have:
- retry
- autoDispose
- family
- restorable
What other big feature would we want? 🤔
from riverpod.
@rrousselGit Some kind of logging mechanism? Not sure if that is possible, just sharing the idea 😅
from riverpod.
What other big feature would we want? 🤔
Do you know recoil js? It is very similar to riverpod :) Maybe we can take some inspiration from them.
But right now, all i am missing is Retry
and i like the idea of .restorable
from riverpod.
I would agree that the change in name convention makes a great deal of sense here.
from riverpod.
Related Issues (20)
- Is it possible to do eager-initialisation of ProviderScopes? HOT 1
- examples/pub dependencies and auth problems HOT 1
- The subclass of AutoDisposeNotifier can always obtain internationalization, even if the phone's system Settings are Chinese, and finally English HOT 2
- Option to ignore previous state in AsyncValue by default HOT 3
- Support async `onDispose` HOT 3
- invalidation forwarding HOT 5
- docs: invalid use of `Uri.https` in readme HOT 1
- Read a HOT 1
- Read a "disposed" notifier HOT 1
- Refactoring Propositions dropping out when updating flutter HOT 2
- Add exception handling to 'ref.refresh()' HOT 6
- Add something like `ref.watchStream(...)` HOT 10
- ProviderScope state wrongly disposed possible bug HOT 3
- Add Japanese docs
- [riverpod_generator] `dependencies` does not respect `provider_family_name_suffix` option
- StateNotifierProvider always refreshs when invalidated problem still exists HOT 3
- Error: 'LintCode' is imported from both 'package /src/dart/error/lint_codes.dart' and 'package /src/lint_codes.dart' on Flutter 3.24.0 with build_runner HOT 3
- VS Code refactoring options are not available with Flutter 3.24 stable release HOT 4
- `initialValue`-like behaviour for the FutureProvider HOT 7
- `flutter` dependency included when using Riverpod in a server-side environment HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from riverpod.