mobx computed value not updating(Observe) on UI at the first time but after reload
429
adding removing or any types of updates to a List is not observed only asigning does, if you want use a List which an be observed Use ObservableList
Author by
Nipun Ravisara
Updated on December 26, 2022Comments
-
Nipun Ravisara over 1 year
I'm using MobX to manage my global state of the app. The problem is I'm using some computed values om my UI but those values not updating on UI but when i print those values in my mobx modal those computed values are computed correctly.
This is my model.
abstract class _User with Store { _User(this.name, this.subjects); @observable String name; @observable List<Spend> subjects; @computed int get totalSubjects => this.subjects.length; @action void addSubject(String name) { subjects.add(Spend(name)); print(totalSubjects); // If i print the value this gives me correct length of subjects array, But this not oberving on UI } }
Only the computed value is not updating. But when i add the subject that subject reflect correctly.
I'm using
flutter_mobx: ^1.1.0+2
andsdk: ">=2.7.0 <3.0.0"