Skip to content

Latest commit

 

History

History
37 lines (26 loc) · 1.59 KB

createEpicMiddleware.md

File metadata and controls

37 lines (26 loc) · 1.59 KB

createEpicMiddleware(rootEpic, [options])

createEpicMiddleware() is used to create an instance of the actual redux-observable middleware. You provide a single, root Epic.

Arguments

  1. rootEpic: Epic: The root Epic
  2. [options: Object]: The optional configuration. Options:
    • dependencies: If given, it will be injected as the 3rd argument to all epics.
    • adapter: An adapter object which can transform the input / output streams provided to your epics. Usually used to adapt a stream library other than RxJS v5, like adapter-rxjs-v4 or adapter-most Options:
      • input: ActionsObservable => any: Transforms the input stream of actions, ActionsObservable that is passed to your root Epic (transformation takes place before it is passed to the root epic).
      • output: any => Observable: Transforms the return value of root Epic (transformation takes place after the root epic returned it).

Returns

(MiddlewareAPI): An instance of the redux-observable middleware.

Example

redux/configureStore.js

import { createStore, applyMiddleware, compose } from 'redux';
import { createEpicMiddleware } from 'redux-observable';
import { rootEpic, rootReducer } from './modules/root';

const epicMiddleware = createEpicMiddleware(rootEpic);

export default function configureStore() {
  const store = createStore(
    rootReducer,
	applyMiddleware(epicMiddleware)
  );

  return store;
}