OnReactive constructor
const
OnReactive(})
First choice widget to listen to an injected state.
It explicitly register injected state consumed in its child widget tree.
Example:
final counter1 = RM.inject(()=> 0) // Or just use extension: 0.inj()
final counter2 = 0.inj();
int get sum => counter1.state + counter2.state;
//In the widget tree:
Column(
children: [
OnReactive( // Will listen to counter1
()=> Text('${counter1.state}');
),
OnReactive( // Will listen to counter2
()=> Text('${counter2.state}');
),
OnReactive(// Will listen to both counter1 and counter2
()=> Text('$sum');
)
]
)
Implementation
const OnReactive(
this.builder, {
this.shouldRebuild,
this.sideEffects,
this.debugPrintWhenRebuild,
this.debugPrintWhenObserverAdd,
Key? key,
}) : super(key: key);