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

Always reapply a snapshot after toggling #526

Closed nhunzaker closed 5 years ago

nhunzaker commented 5 years ago

This commit fixes a bug where toggling an action would not invalidate snapshot cache state, resulting in an incorrect state:

repo.addDomain('test', {
  getInitialState() {
    return true
  }
})

let action = repo.reset({ test: false })

action.toggle()

expect(repo).toHaveState('test', true)
action.toggle()
expect(repo).toHaveState('test', false) // This failed

The solution is to track disabled action state as a part of the snapshot, just like the status and payload field.

Resolves: https://github.com/vigetlabs/microcosm/issues/525