Open subzero911 opened 2 years ago
Just use reaction
then? https://mobx.netlify.app/api/reaction/#reaction
Or write custom wrapper around it, probably just couple lines of code
You could do something like this.
import 'package:mobx/mobx.dart';
ReactionDisposer reactionWhere(
bool Function(Reaction) where,
void Function() effect, {
String? name,
int? delay,
bool? fireImmediately,
ReactiveContext? context,
void Function(Object, Reaction)? onError,
}) {
return reaction<bool>(
(rxn) => where(rxn),
(value) {
if (value) effect();
},
name: name,
delay: delay,
fireImmediately: fireImmediately,
context: context,
onError: onError,
);
}
Currently
when
andasyncWhen
always dispose itself after it fires. But sometimes that's not what I need. I may want to fire thewhen
reaction multiple times. Please add a parameterautodispose: true/false
, to control this behaviour. It could be optional and true by default, to not ruin the current applications.