Replies: 1 comment 5 replies
-
This is a voluntary decision. The goal is to have autoDispose on by default. In the future, defining providers manually will be deprecated/removed (once we have metaprogramming). At that point, we'll have only one scenario: autodispose on by default. It is enabled by default because this is generally the better option when using Riverpod correctly. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, providers that are created through code generation are set to be automatically destroyed when the state of a provider is no-longer used (i.e. - autodispose). However, providers which are created manually are not automatically destroyed. Instead, the developer must explicitly specify this as a desired behavior by using
.autodispose
. This creates a bit of confusion for developers who decide to use code generation for the first time after having routinely created their providers manually in the past. They expect the generated provider to havekeepAlive = true
by default, just as it would be if they created the provider manually (without explicitly specifying to use.autodispose
).Ultimately, it might be a good idea for us to try to stick to one convention, if we can.
keepAlive
istrue
by default for all providers orkeepAlive
isfalse
by default for all providers, regardless of whether they're created manually or automatically.Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions