Something like proposed here: https://github.com/mobxjs/mobx.dart/issues/218#issuecomment-509991708
All current workarounds are verbose and require manual field list sync on model structure changes, e.g. new fields added to model.
I am happy to assist anyone willing to start a PR on the any reaction :-). I think it would be a great addition to MobX.
As @rrousselGit proposed, we need an any atom that will report anytime there is a read/write to any of the Store properties.
mobx_codegen as part of the Store code template. @storeConfig PR (#414) We will pick this up once #414 is merged
Cannot we write the any reaction as something like this: (I am using it like this, but it is very verbose)
dart
ReactionDisposer any(
List<dynamic Function(Reaction)> fns,
void Function() effect, {
String name,
int delay,
bool fireImmediately,
ReactiveContext context,
void Function(Object, Reaction) onError,
}) {
List<dynamic> fn(Reaction reaction) => fns.map((f) => f(reaction)).toList();
return reaction<List<dynamic>>(
fn,
(c) => effect(),
delay: delay,
name: name,
fireImmediately: fireImmediately,
context: context,
equals: (dynamic lst1, dynamic lst2) {
return //false;
ListEquality().equals(lst1, lst2);
},
onError: onError,
);
}
Of course, we lose the equals on the individual fns, but maybe the above method can be extended to take into account this case too.
It is also a little bit verbose since all the tracked Observables must be "declared" in the list of fns.
This does not solve the verbosity of the method above but it may work. The verbosity can be solved when the code generated store will have something like a list of all Observables so that the tracked Observables of a store can be inferred not explicitly declared!
Most helpful comment
We will pick this up once #414 is merged