set method

void set(
  1. String name,
  2. Object? value, {
  3. bool pristine = false,
  4. bool local = true,
})

Implementation

void set(
  String name,
  Object? value, {
  bool pristine = false,
  bool local = true,
}) {
  if (local) _localWrites.add(name);
  if (pristine) {
    _pristine.add(name);
  } else {
    _pristine.remove(name);
  }
  final existing = _state[name];
  if (_state.containsKey(name) && Js.objectIs(existing, value)) return;
  if (value is Map && existing is Map && value.length == existing.length) {
    if (value.keys.every(
      (k) => existing.containsKey(k) && Js.objectIs(value[k], existing[k]),
    )) {
      return;
    }
  }
  _state[name] = value;
  _notify();
}