npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

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.

Keywords

none

install

npm i fusion-plugin-redux-observable

Downloadsweekly downloads

0

version

0.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability