promote method

bool promote(
  1. int id
)

Commits one optimistic layer to the base store by hand. Refused when the layer touches an owned entity; the layer stays on the stack.

Implementation

bool promote(int id) {
  _ready();

  for (final layer in _cache.overlays()) {
    if (layer.id != id) continue;

    for (final patch in layer.patches) {
      if (_cache.ownsKey(patch.key)) {
        _refuse('promote a change to', patch.key);
      }
    }
  }

  if (!_cache.promoteOverlay(id)) return false;

  _record(ActionKind.rollback, 'promote overlay #$id');
  _cache.notifyChanged();

  return true;
}