How to use the redux-observable.createEpicMiddleware function in redux-observable

To help you get started, we’ve selected a few redux-observable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github django-stars / frontend-skeleton / src / app / init.js View on Github external
}


// support for redux dev tools
const compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || reduxCompose

const store = createStore(
  combineReducers({
    form,
    resource,
    ...reducers,
  }),
  initialState,
  compose(
    applyMiddleware(...[
      createEpicMiddleware(combineEpics(...epics, resourceEpic), { dependencies: { API } }),
      cacheMiddleware,
      process.env.SENTRY_DSN && createSentryMiddleware(Sentry, {
        stateTransformer: (state) => { return omit(state, 'session') },
      }),
    ].filter(Boolean))
  )
)

// FIXME API should not need store
configureAPI(store)
const history = createBrowserHistory()

export {
  store,
  history,
}
github uqutub / learn-react-js / ReactNative / Redux-Epic / src / store / index.js View on Github external
import { GitEpic } from './epic/github';

// Application Reducers
const rootReducer = combineReducers({
    counterReducer: counterReducer,
    todoReducer: todoReducer,
    gitReducer: githubReducer
});

export const rootEpic = combineEpics(
    GitEpic.getRepoData,
    GitEpic.getFollowersData
    // more epics functions go here
)

const epicMiddleware = createEpicMiddleware(rootEpic);

const createStoreWithMiddleware = applyMiddleware(epicMiddleware);

export let store = createStore(rootReducer, createStoreWithMiddleware);
github nteract / nteract / applications / desktop / src / notebook / middlewares.js View on Github external
/* @flow strict */
import { middlewares as coreMiddlewares } from "@nteract/core";

import { createEpicMiddleware, combineEpics } from "redux-observable";

import logger from "./logger.js";
import epics from "./epics/index.js";

const rootEpic = combineEpics(...epics);

const middlewares = [
  createEpicMiddleware(rootEpic),
  coreMiddlewares.errorMiddleware
];

if (process.env.DEBUG === "true") {
  middlewares.push(logger());
}

export default middlewares;
github cennznet / runanode / app / renderer / store / development.js View on Github external
import { createStore, applyMiddleware, compose } from 'redux';
import { createEpicMiddleware } from 'redux-observable';
import { routerMiddleware } from 'connected-react-router';
import history from 'renderer/history';
import { createLogger } from 'redux-logger';
import gaMiddleware from './middlewares/analytics';
import rootReducer from '../reducers';
import epics from '../epics';

const middleware = [];

const epicMiddleware = createEpicMiddleware();
middleware.push(epicMiddleware);

const LOG_REDUX = false;

// Skip redux logs in console during the tests
if (process.env.NODE_ENV !== 'test' && LOG_REDUX) {
  // Logging Middleware
  const logger = createLogger({
    level: 'info',
    collapsed: true,
  });
  middleware.push(logger);
}

middleware.push(routerMiddleware(history));
middleware.push(gaMiddleware({ logger: false }));
github jsmentor / react-workshops / apps / user-management-app / src / store / configureStore.js View on Github external
export default function configureStore(initialState, helpersConfig) {
  const helpers = createHelpers(helpersConfig);

  const sagaMiddleware = createSagaMiddleware();

  const epicMiddleware = createEpicMiddleware(epics);

  const middlewares = [
    epicMiddleware,
    sagaMiddleware,
    thunk.withExtraArgument(helpers)
    // beforeLoggerMiddleware,
    // afterLoggerMiddleware,
  ];

  let enhancer;

  if (__DEV__) {
    middlewares.push(createLogger());

    // https://github.com/zalmoxisus/redux-devtools-extension#redux-devtools-extension
    let devToolsExtension = f => f;
github Wonder-Technology / Wonder-Editor / demo / observable / PING / index.tsx View on Github external
import * as React from "react";
import * as ReactDOM from "react-dom";
import {createStore} from "redux";
import {createEpicMiddleware} from "redux-observable";
import {pingEpic, pingReducer} from "./reducers/reducer";
import {applyMiddleware} from "redux";
import {Provider} from "react-redux";
import App from "./containers/App";

const epicMiddleware = createEpicMiddleware(pingEpic);
//noinspection TypeScriptValidateTypes
let store = createStore(pingReducer,applyMiddleware(epicMiddleware));
ReactDOM.render(
    <div>
        
            
        
    </div>,
    document.querySelector("#ct")
);
github wavesplatform / wavesplatform.com / src / public / render / createStore.js View on Github external
const appInitialState = {
    page: initialState,
  };

  const appEpic = combineEpics(
    epic,
    patchEpicStore(s => s.common.cookieConsent, cookieConsentEpic)
  );

  const store = createReduxStore(
    appReducer,
    appInitialState,
    compose(
      customMiddleware,
      applyMiddleware(thunk),
      applyMiddleware(createEpicMiddleware(appEpic)),
      window.devToolsExtension ? window.devToolsExtension() : f => f
    )
  );

  return store;
};
github geosolutions-it / MapStore2 / web / client / examples / plugins / store.js View on Github external
module.exports = (plugins, custom) => {
    const allReducers = combineReducers(plugins, {
        locale: require('../../reducers/locale'),
        browser: require('../../reducers/browser'),
        theme: require('../../reducers/theme'),
        map: () => {return null; },
        mapInitialConfig: () => {return null; },
        layers: () => {return null; },
        pluginsConfig: require('./reducers/config'),
        custom
    });
    const standardEpics = {
        ...require('../../epics/controls')
    };
    const rootEpic = combineEpics(plugins, {...standardEpics });
    const epicMiddleware = createEpicMiddleware(rootEpic);

    const rootReducer = (state, action) => {
        if (action.type === 'LOADED_STATE') {
            return action.state;
        }
        let mapState = LayersUtils.splitMapAndLayers(mapConfig(state, action));
        let newState = {
            ...allReducers(state, action),
            map: mapState && mapState.map ? map(mapState.map, action) : null,
            mapInitialConfig: mapState ? mapState.mapInitialConfig : null,
            layers: mapState ? layers(mapState.layers, action) : null
        };
        return newState;
    };

    return createDebugStore(rootReducer, {}, [epicMiddleware]);
github rwieruch / react-redux-soundcloud / extension-observable / src / stores / configureStore.js View on Github external
import { createStore, applyMiddleware } from 'redux';
import createLogger from 'redux-logger';
import { createEpicMiddleware } from 'redux-observable';
import { browserHistory } from 'react-router';
import { routerMiddleware } from 'react-router-redux';
import { rootEpic } from '../actions/index';
import rootReducer from '../reducers/index';

const logger = createLogger();
const router = routerMiddleware(browserHistory);

const epicMiddleware = createEpicMiddleware(rootEpic);
const createStoreWithMiddleware = applyMiddleware(epicMiddleware, router)(createStore);

export default function configureStore(initialState) {
  return createStoreWithMiddleware(rootReducer, initialState);
}
github Donmclean / riko / src / js / components / Shared / CounterClicker / counterClicker.spec.js View on Github external
import React from 'react';
import * as counterActions from './counterActionCreators';
import * as types from '../../../constants/actionTypes';
import counterReducer, { initialState } from './counterReducer';

//Include Redux Observable For 'Epic' Creation
import { epics } from '../../../_Epics';
import { createEpicMiddleware } from 'redux-observable';
const epicMiddleware = createEpicMiddleware(epics);

import { Map } from 'immutable';

//For testing components
import { shallow } from 'enzyme';
import renderer from 'react-test-renderer';
import configureStore from 'redux-mock-store';
const middlewares = [epicMiddleware]; //eg: [thunk] for async | eg: [epicMiddleware] for testing epics
const mockStore = configureStore(middlewares);

//Component to be Tested
import CounterClicker from './index';

//Test suite designed to test the functionality of
describe('Counter Test Suite', () => {
    let store;