react-reduce-observable
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha.1 • Public • Published

react-reduce-observable

Build Status

A shameless "clone" of redux-observable for the built-in React reducer. 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.

Install

npm install --save react-reduce-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. To create your context, pass in your reducer, epics, and dependencies.

const {Provider, useObservableContext} = createObservableReducerContext(myReducer, [
    myEpic
], dependencies);
<Provider options={{
    state: defaultState
}}>
    <MyComponent/>
</Provider>
import {FunctionComponent} from "react";

export const MyComponent: FunctionComponent = () => {

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

}

Readme

Keywords

Package Sidebar

Install

npm i react-reduce-observable

Weekly Downloads

1

Version

1.0.0-alpha.1

License

MIT

Unpacked Size

22.2 kB

Total Files

15

Last publish

Collaborators

  • anigenero