[etos_flutter] We need a way to easily access the current state from scope
Closed this issue · 1 comments
SEGVeenstra commented
For example in the initState
when you need to perform an action on the current state.
Something like:
@override
void initState() {
final currentState = EtosProvider.of(context).state;
if(currentState.hasLoadedItems == false) {
context.dispatch(LoadItemsEvent());
}
}
NOTE: currently EtosProvider.of(context)
returns an untyped Etos
instance because it was only meant to dispatch
.
SEGVeenstra commented
We can get the state from:
Tstate get state => _statesController.value;
Which is already part of Etos