react-state-rxjs
  • Introduction
  • Main differences
  • Performance first
  • GETTING STARTED
    • Instalation
    • Examples
  • Core concepts
    • Main idea
      • More complex flow visualization
    • Configuration
    • Store
      • Operators
      • Optimistic updates plugin
      • Form manager plugin
        • ShouldUpdateState hook
        • Custom form elements
      • Persist state plugin
        • Configuring custom storage
    • Actions
      • Immer
      • ImutableJs
      • Async
    • Components with Actions
    • @InjectStore decorator
    • @ComponentState decorator
    • ComponentState Hook
    • Dispatcher
    • Router / History
  • DIFFERENT SCENARIOS
    • Passing list item index via router
  • UNIT TESTING
    • Setup
    • Test store
    • Test actions
    • Test component with actions
    • Test with Enzyme
  • Debugging
    • Setup
    • Redux DevTools
    • Automated changes output
    • Manual state changes check
    • Additional debugging information
  • Production
    • Production mode
  • Other information
    • Best practices
    • CLI
      • Custom Configurations
    • Performance
    • Blog Posts
    • Contributing
Powered by GitBook
On this page

Was this helpful?

  1. Core concepts
  2. Store

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!

PreviousOperatorsNextForm manager plugin

Last updated 5 years ago

Was this helpful?