redux-observable-util
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

redux-observable-util

npm version CircleCI

Redux Observable Util is a helper library for using Redux and Redux Observable in TypeScript. It contains some helper functions and a simplified Epic setup.

Table of Contents

Peer Dependencies

Module Version
redux ^4.0.0
redux-observable ^1.0.0
rxjs ^6.0.0

Defining Redux Observable Epics

Redux Observable Util simplifies the setup for defining an epic, cleaning up the code for readability.

Before

somethingEpic = (action$, state$) =>
  action$.pipe(
    ofType('SOMETHING'),
    switchMap(() =>
      // Add logic

      return { type: 'SUCCESS', something: 'something' };
    )
  );

After

@Epic('SOMETHING')
somethingEpic(action: AnyAction, state$: any) {
  // Add logic

  return { type: 'SUCCESS', something: 'something' };
}

Configuring Epics in Store

Configuration of the epics is also simplified compared to the standard setup of Redux Observable. You call the generateEpics instead of combineEpics, and pass the services that contain @Epic decorators.

Before

const epicMiddleware = createEpicMiddleware();
export const store = createStore(rootReducer, applyMiddleware(epicMiddleware));
epicMiddleware.run(combineEpics(Service.epic1, Service.epic2));

After

const epicMiddleware = createEpicMiddleware();
export const store = createStore(rootReducer, applyMiddleware(epicMiddleware));
epicMiddleware.run(generateEpics(Service));

Readme

Keywords

Package Sidebar

Install

npm i redux-observable-util

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

118 kB

Total Files

29

Last publish

Collaborators

  • kanefreeman