> For the complete documentation index, see [llms.txt](https://vytautaspranskunas.gitbook.io/react-state-rxjs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vytautaspranskunas.gitbook.io/react-state-rxjs/core-concepts/store/optimistic-updates-plugin.md).

# 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.

```typescript
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!
