write<T> method

  1. @override
void write<T>(
  1. StateRef<T> ref,
  2. T state, [
  3. Object? action
])
override

Updates the value of the state referenced by ref with state.

An optional action can be send to track which method did the update.

Implementation

@override
void write<T>(StateRef<T> ref, T state, [Object? action]) {
  onWrite?.call(ref, state, action);
  final T oldState =
      _states.containsKey(ref.key) ? _states[ref.key] as T : ref.initialState;
  _states[ref.key] = state;
  _mementoObserver.didChanged(ref, oldState, state, action);
}