updateCustom method

void updateCustom(
  1. State? fn(
    1. State? custom
    )
)

Updates the custom state of the session using a mutator function.

The current custom state is parsed into a State, handed to fn, and the returned State is serialized back to plain JSON before storing. Storage stays plain JSON so the customChanged -> customPatch streaming diff keeps working unchanged.

Implementation

void updateCustom(State? Function(State? custom) fn) {
  final next = fn(castOrParseState<State>(_json['custom'], _stateSchema));
  _json['custom'] = serializeState<State>(next, _stateSchema);
  _version++;
  _emit('customChanged');
}