-
-
Notifications
You must be signed in to change notification settings - Fork 896
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
Where should I put Computed? #7
Comments
You could set them as static variables on your Model Like: class MyNotifier extends StateNotifier {
static final myComputed =Computed(...)
} Or keep them all in the same file |
Is there any memory problem if I have many static variables ? |
No. That's the same thing as using global variables. |
Yep. Thanks! |
What if it's not global nor static? class Counter with ChangeNotifier {
int value1;
int value2;
...
}
...
@override
Widget build(BuildContext context) {
final computed = Computed((read) => read(counterProvider).value1);
return Text('value: ${read(computed)});
} |
Bad idea, at least for now. |
If you want a "select", there's one for hooks:
|
OK, I'll think about using hooks, hoping it'll be improved in the future. |
What is your need to begin with?
…On Wed, 24 Jun 2020, 10:33 Kabo, ***@***.***> wrote:
OK, I'll think about using hooks, hoping it'll be improved in the future.
Thanks anyway!
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#7 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEZ3I3IBTGEWJBHJWSD5J6LRYHB53ANCNFSM4OF3DZ6Q>
.
|
@rrousselGit But it may not be so bad. Probably I'm just having some difficulty, at this early stage, accepting the fact that |
@tbm98 |
@kaboc no, but I think |
Computed is cached and shared |
Got it. I'll tell it to myself again and again until I accept it. |
As far as I know,
Computed
is like a filter and it only calculates and notifiesConsumer
when there's a change. So in case I have a complex state, I need a lot ofComputed
, should I set myComputed
as global variables or set it as static variables or something else?If I set as global variables, I can't remember them all 😕
The text was updated successfully, but these errors were encountered: