dispatch method
Dispatch an action to update state
Implementation
void dispatch(Action action) {
try {
final newState = _reducer(value, action);
Transaction.run(() {
value = newState;
});
if (_enableHistory) {
_actionHistory.add(action);
if (_actionHistory.length > _historyLimit) {
_actionHistory.removeAt(0);
}
}
Logger.debug('Action dispatched: ${action.type}', action.payload);
} catch (e) {
Logger.error('Error dispatching action: ${action.type}', e);
rethrow;
}
}