fusion-plugin-redux-observable

0.1.0 • Public • Published

fusion-plugin-redux-observable

Installs the redux-observable middleware and runs the provided epic.


Table of contents


Installation

yarn add fusion-plugin-redux-observable

Usage

// epic.js
// plain ol' epic
import { ofType } from 'redux-observable';
import { delay, mapTo } from 'rxjs/operators';
import { PING, pong } from './actions';

export default action$ =>
  action$.pipe(
    ofType(PING),
    delay(1000),
    mapTo(pong()),
  );

Setup

// main.js
import React from 'react';
import Redux, {
  ReduxToken,
  ReducerToken,
  EnhancerToken,
  GetInitialStateToken,
} from 'fusion-plugin-react-redux';
import EpicEnhancer, { EpicToken, EpicEnhancerToken } from 'fusion-plugin-redux-observable';
import App from 'fusion-react';
import { createPlugin } from 'fusion-core';
import { compose } from 'redux';
import reducer from './reducer';
import epic from './epic';

export default () => {
  const app = new App(root);
  app.register(ReduxToken, Redux);
  app.register(ReducerToken, reducer);
  app.register(EpicToken, epic);
  app.register(EpicEnhancerToken, EpicEnhancer);
  app.register(EnhancerToken, createPlugin({
    deps: { epicEnhancer: EpicEnhancerToken },
    provides: ({ epicEnhancer }) => compose(epicEnhancer),
  }));
  __NODE__ && app.register(GetInitialStateToken, async ctx => ({}));
}

API

Registration API

EpicEnhancer
import EpicEnhancer from 'fusion-plugin-redux-observable';

The redux-observable enhancer. Installs middleware and runs required epic registered to EpicToken. Typically registed to EpicEnhancerToken

EpicEnhancerToken
import { EpicEnhancerToken } from 'fusion-plugin-redux-observable';

Typically registered with EpicEnhancer

Dependencies

EpicToken
import { EpicToken } from 'fusion-plugin-redux-observable';

The root epic. Required.

Readme

Keywords

none

Package Sidebar

Install

npm i fusion-plugin-redux-observable

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

29.3 kB

Total Files

19

Last publish

Collaborators

  • icculusc