> For the complete documentation index, see [llms.txt](https://tonyding.gitbook.io/angular/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tonyding.gitbook.io/angular/redux.md).

# Redux

## Waht's Redux

A library that helps you manage the state of your application

## Benefits

* Predicatable application state
* Decoupled architecture
* Testability
* Great tooling
* Undo/Redo

## When to use Redux

* Independent copies of the same data in multiple places
* Multiple views that need to work with the same data and be in sync
* Data can be updated by multiple users
* Data can be updated by multiple actors

## Building Block

### The Store

A single JS object that contains the state of the application (like local client-side database)

### Actions

Plain JS object that represent something that has happened. (more like an Events)

```
{type: 'MARKS_AS_READ'}
{type: 'POST_MESSAGE', body: '...'}
```

### Reducer

A function that specifies how that state changes in response to an action (like event handler)

A reducer does not modify the state, It returns the new state
