vigetlabs / microcosm

Flux with actions at center stage. Write optimistic updates, cancel requests, and track changes with ease.
http://code.viget.com/microcosm/
MIT License
487 stars 22 forks source link

Batch delete action snapshots #439

Closed nhunzaker closed 6 years ago

nhunzaker commented 6 years ago

Microcosm master batch processes snapshots given a history range. We can do the same thing with removing snapshots. Basically, instead of:

_removeSnapshot(action: Action) {
  delete this.snapshots[action.id]
}

We could match the pattern for updating a snapshot range:

_removeSnapshotRange(source: Action, end: Action) {
  let focus = source
  while (focus && this.snapshots.hasOwnProperty(focus.id)) {
    delete this.snapshots[focus.id]
  }
}

There are two benefits:

  1. History does not have to emit an action for every item it removes.
  2. Microcosms can stop removing snapshots when they are out of snapshots
nhunzaker commented 6 years ago

Implementation details have changed here.