# react-reducer-observable

> rxjs observable patterns for React reducers

Latest version **1.0.0** (published 2021-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-reducer-observable
pnpm add react-reducer-observable
yarn add react-reducer-observable
bun add react-reducer-observable
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-05-17 |
| First published | 2021-01-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 34.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Robin Schultz |
| Maintainers | anigenero |
| Keywords | react, reduce, rxjs |

## Links

- npm: https://www.npmjs.com/package/react-reducer-observable
- Repository: https://github.com/anigenero/react-reducer-observable
- Homepage: https://github.com/anigenero/react-reducer-observable#readme
- Issues: https://github.com/anigenero/react-reducer-observable/issues
- npm.io page: https://npm.io/package/react-reducer-observable

## Dependencies (1)

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

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2021-05-17
- 1.0.0-beta.3 (next) — 2021-03-15
- 1.0.0-beta.2-1 — 2021-03-12
- 1.0.0-beta.2 — 2021-03-12
- 1.0.0-beta.1 — 2021-02-26
- 1.0.0-alpha.1 — 2021-01-29

## README

# react-reducer-observable

[![Build Status](https://travis-ci.org/anigenero/react-reducer-observable.svg?branch=main)](https://travis-ci.org/anigenero/react-reducer-observable)

A shameless "clone" of redux-observable for the built-in React reducer (flux). The idea is to reduce or remove entirely the
redux footprint in components that don't require access to a global state tree but still need to manage dispatch events 
in an observable pattern. This allows state to be contextual.

## Install

```bash
npm install --save react-reducer-observable
```

## Usage

Like redux-observable, this library centers around the idea of epics. You can read more about how epics are constructed 
and its core concepts [here](https://redux-observable.js.org/docs/basics/Epics.html). To create your context, pass in your 
reducer, epics, and dependencies.

```typescript
const {Provider, useObservableContext} = createObservableReducerContext(myReducer, [
    myEpic
], dependencies);
```

```typescript jsx
<Provider options={{
    state: defaultState
}}>
    <MyComponent/>
</Provider>
```

```typescript jsx
import {FunctionComponent} from "react";

export const MyComponent: FunctionComponent = () => {

    const {state, dispatch} = useObservableContext();
    
    return (
        <button onClick={() => dispatch(myAction())}>
            Click Me!
        </button>
    );

}
```

## Limitations

Due to the React's reducer state being tied to the component tree lifecycle, there is no way to reliably provide a current state to the epics. Any 
action(s) that requires visibility into the state will have to be done through the reducer.

---
_Source: https://npm.io/package/react-reducer-observable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
