Skip to content

Latest commit

 

History

History
 
 

api

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

API

This document uses rtype for type signatures.

wrapRootEpic

Wraps your rootEpic in a function that allows renderToString to inspect the observables within the epicMiddleware.

Type Signature

import interface { Epic } from 'redux-observable';

interface WrappedEpic { ...Epic };

Usage

import { createEpicMiddleware } from 'redux-observable';
import { wrapRootEpic } from 'react-redux-epic';
import { fetchDataCompleteActionCreator } from './action-creators.js';

const rootEpic = actions => actions.ofType('FETCH').switchMap(() => Observable
  .ajax('/api/data')
  .map(fetchDataCompleteActionCreator);
);

const wrappedEpic = wrapRootEpic(rootEpic);
const epicMiddleware = createEpicMiddleware(wrappedEpic);

renderToString

renderToString takes your wrappedEpic and your react app and will trigger a render, wait for all of your epics to complete, then trigger a final render.

Type Signature

renderToString(
  element: ReactElement,
  wrappedEpic: WrappedEpic
) => Observable[{ markup: String }];

Usage

import { renderToString } from 'react-redux-epic';

renderToString(<App />, wrappedEpic)
  .subscribe(({ markup }) => {
    // if using Express
    res.render('index', { markup });
  });

render

Optional: Wraps react-dom's render method in an observable. Calls next when the render is complete.

Type Signature

render(
  element: ReactElement,
  container: DOMElement
) => Observable;

Usage

import { render } from 'react-redux-epic/client';

render(<App />, document.getElementById('app-div'))
  .subscribe(() => console.log('rendered!'));