# @reactive-redux/async-store

> Reactive state container

Latest version **3.1.3** (published 2019-02-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @reactive-redux/async-store
pnpm add @reactive-redux/async-store
yarn add @reactive-redux/async-store
bun add @reactive-redux/async-store
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.3 |
| Published | 2019-02-07 |
| First published | 2018-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 33.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Zdravko Tatarski |
| Maintainers | be-reactive |
| Keywords | rxjs, redux, reactive redux, state container, reactive container |

## Links

- npm: https://www.npmjs.com/package/@reactive-redux/async-store
- Homepage: https://github.com/reactive-redux/async-store
- npm.io page: https://npm.io/package/@reactive-redux/async-store

## Dependencies (1)

- [rxjs](https://npm.io/package/rxjs.md) 6.4.0

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 3.1.3 (latest) — 2019-02-07
- 3.1.2 — 2019-02-07
- 3.1.1 — 2019-02-06
- 3.1.0 — 2019-02-06
- 3.0.2 — 2019-02-03
- 3.0.1 — 2019-02-03
- 3.0.0 — 2019-02-03
- 2.0.1 — 2019-02-02
- 2.0.0 — 2019-02-02
- 1.5.4 — 2019-01-31
- 1.5.3 — 2019-01-30
- 1.5.2 — 2019-01-30
- 1.5.1 — 2019-01-30
- 1.5.0 — 2019-01-26
- 1.4.6 — 2019-01-25
- … 31 more at https://npm.io/package/@reactive-redux/async-store/versions

## README

[![npm version](https://badge.fury.io/js/%40reactive-redux%2Fasync-store.svg)](https://badge.fury.io/js/%40reactive-redux%2Fasync-store)

# Reactive state container

## Install

#### `npm i @reactive-redux/async-store`

## Example

```typescript
import { of, Subject, interval } from 'rxjs';
import { map, take } from 'rxjs/operators';
import {
  Action,
  AsyncStore,
  AsyncType,
  select
} from '@reactive-redux/async-store';

//Counter example
interface State {
  count: number;
}

class Increment extends Action {
  constructor(public payload: number) {
    super();
  }
}

class Decrement extends Action {
  constructor(public payload: number) {
    super();
  }
}

type ActionsUnion = Increment | Decrement;

const actionQ = new Subject<AsyncType<ActionsUnion>>();

const initialState = {
  count: 0
};

const initialState$ = of(initialState);
const actions$ = actionQ.asObservable();

const actionMap$ = of({
  [Increment.name]: (state: State, action: Increment) => ({
    ...state,
    count: state.count + action.payload
  }),
  [Decrement.name]: (state: State, action: Decrement) => ({
    ...state,
    count: state.count - action.payload
  })
});

const store = new AsyncStore<State, ActionsUnion>({
  initialState$,
  actions$,
  actionMap$
});

store.state$.pipe(select(state => state.count)).subscribe(console.log);

const add100 = new Increment(100);

const add100times5 = interval(200).pipe(
  map(() => add100),
  take(5)
);

actionQ.next(add100times5);
```

## Changelog

## Want to help?

---
_Source: https://npm.io/package/@reactive-redux/async-store · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
