context_watch_mobx 3.0.1 context_watch_mobx: ^3.0.1 copied to clipboard
context_watch adapter for mobx package
See https://pub.dev/packages/context_watch
Usage #
Add MobxContextWatcher.instance
to additionalWatchers
of ContextPlus.root
:
ContextPlus.root(
additionalWatchers: [
MobxContextWatcher.instance,
],
child: ...,
);
Observe MobX Observable
with Observable.watch(context)
or Observable.watchOnly(context, () => ...)
, without wrapping anything with Observer
or subclassing the ObserverStatelessWidget
:
final _counter = Observable(0);
class Example extends StatelessWidget {
@override
Widget build(BuildContext context) {
final counter = _counter.watch(context);
return Text('Counter: $counter');
}
}