Optimistic updates plugin

Optimistic updates are updates before API call

In order to make UI feel like native we need to performa optimistic updates. But these updates comes with price of reverting state if something went wrong during API calls. This plugin helps to solve this.

this.store.optimisticUpdates.revertLastChanges(2);

API:

  • tagCurrentState(tag: string) - you can tag current state to know where to revert to.

  • revertToTag(tag: string) - revert state to tag in case of failure

  • revertToLastTag() - revert to last tag available

  • revertLastChanges(count: number) - revert N changes

Remember that root level store reverts whole state while nested (actions) level store reverts only state that it is responsible for!

Last updated