How to use the redux-loop.install function in redux-loop

To help you get started, we’ve selected a few redux-loop 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 apollographql / react-apollo / test / react-web / client / libraries / redux.tsx View on Github external
default:
            return state;
          }
      }

      // initial state, accessor and mutator for supporting root-level
      // immutable data with redux-loop reducer combinator
      const immutableStateContainer = Map();
      const getImmutable = (child, key) => child ? child.get(key) : void 0;
      const setImmutable = (child, key, value) => child.set(key, value);

      const store = createStore(
        loopCombine({
          counter,
        }, immutableStateContainer as any, getImmutable, setImmutable),
        install()
      );

      @connect((state) => ({ first: state.get('counter') }))
      @graphql(query)
      class Container extends React.Component {
        componentWillReceiveProps(nextProps) {
          if (nextProps.first === 1) this.props.dispatch({ type: 'INCREMENT' });
          if (nextProps.first === 2) {
            if (nextProps.data.loading) return;
            expect(nextProps.data.allPeople).to.deep.equal(data2.allPeople);
            done();
          }
        }
        render() {
          return null;
        }
github apollographql / react-apollo / test / react-web / client / libraries / redux.tsx View on Github external
return state + 1;
          default:
            return state;
          }
      }

      // Typscript workaround
      const apolloReducer = client.reducer() as () => any;

      const store = createStore(
        loopCombine({
          counter,
          apollo: apolloReducer,
        }),
        applyMiddleware(client.middleware()),
        install()
      );

      @connect((state) => ({ first: state.counter }))
      @graphql(query)
      class Container extends React.Component {
        componentWillReceiveProps(nextProps) {
          if (nextProps.first === 1) this.props.dispatch({ type: 'INCREMENT' });
          if (nextProps.first === 2) {
            if (nextProps.data.loading) return;
            expect(nextProps.data.allPeople).to.deep.equal(data2.allPeople);
            done();
          }
        }
        render() {
          return null;
        }
github minedeljkovic / redux-elmish / src / install.js View on Github external
return (createStore) => (update, initialState, enhancer) => {
    initialState = initialState || toReduxLoop(init()); // eslint-disable-line no-param-reassign
    function reducer(state, action) {
      if (isReduxAction(action)) return state;
      return toReduxLoop(update(state, action));
    }

    const loopEnhancer = loopInstall();
    return loopEnhancer(createStore)(reducer, initialState, enhancer);
  };
}
github raisemarketplace / ground-control / examples / createStore.js View on Github external
export default ({
  additionalReducers, enableReactRouterRedux, enableDevTools, enableThunk, enableLoop, history,
}) => {
  let middleware = [];
  let reactRouterReduxMiddleware;
  if (enableThunk) middleware = middleware.concat(thunk);
  if (enableReactRouterRedux && history) reactRouterReduxMiddleware = syncHistory(history);
  if (reactRouterReduxMiddleware) middleware = middleware.concat(reactRouterReduxMiddleware);

  let storeEnhancers = [];
  if (enableLoop) storeEnhancers = storeEnhancers.concat(installLoop()); // this should come last, but devtools causes issue
  if (enableDevTools) storeEnhancers = storeEnhancers.concat(window.devToolsExtension ? window.devToolsExtension() : f => f);

  const reducers = additionalReducers && !isEmpty(additionalReducers) ? additionalReducers : {};
  if (enableReactRouterRedux) reducers.routing = routeReducer;

  const defaultReducer = (state = {}) => state;
  const cr = enableLoop ? loopCombineReducers : reduxCombineReducers;
  const reducer = isEmpty(reducers) ? defaultReducer : cr({
    [NAMESPACE]: defaultReducer, // need to set if using combineReducers top level...
    ...reducers,
  });

  const store = createStore(reducer, {}, compose(
    applyMiddleware(...middleware),
    ...storeEnhancers
  ));
github Imater / 4redux / src / redux / create.js View on Github external
export default function createStore(history, data) {
  const reduxRouterMiddleware = routerMiddleware(history);

  // const middleware = [createMiddleware(client), reduxRouterMiddleware];

  let finalCreateStore;
  if (__DEVELOPMENT__ && __CLIENT__ && __DEVTOOLS__) {
    const { persistState } = require('redux-devtools');  // eslint-disable-line global-require
    const DevTools = require('../containers/DevTools/DevTools');  // eslint-disable-line global-require
    finalCreateStore = compose(
      install(),
      applyMiddleware(reduxRouterMiddleware),
      window.devToolsExtension ? window.devToolsExtension() : DevTools.instrument(),
      persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
    )(_createStore);
  } else {
    finalCreateStore = compose(
      install(),
      applyMiddleware(reduxRouterMiddleware)
    )(_createStore);
  }

  const reducer = require('./modules/reducer');  // eslint-disable-line global-require
  const store = finalCreateStore(reducer, data);

  // reduxRouterMiddleware.listenForReplays(store);
github Imater / 4redux / src / store / create.js View on Github external
const createStore = (history, data) => {
  const reduxRouterMiddleware = routerMiddleware(history)

  // const middleware = [createMiddleware(client), reduxRouterMiddleware];

  let finalCreateStore
  if (__DEVELOPMENT__ && __CLIENT__ && __DEVTOOLS__) {
    const { persistState } = require('redux-devtools') // eslint-disable-line global-require, import/no-extraneous-dependencies
    const DevTools = require('../containers/DevTools/DevTools') // eslint-disable-line global-require

    finalCreateStore = compose(
      install(),
      applyMiddleware(reduxRouterMiddleware),
      window.devToolsExtension ? window.devToolsExtension() : DevTools.instrument(),
      persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
    )(_createStore)
  } else {
    finalCreateStore = compose(
      install(),
      applyMiddleware(reduxRouterMiddleware)
    )(_createStore)
  }

  const store = finalCreateStore(makeReducers(), data)

  store.asyncReducers = {}

  // reduxRouterMiddleware.listenForReplays(store);
github FormidableLabs / redux-little-router / test / store-enhancer.spec.js View on Github external
const enhancers = [
    createStoreWithSpy,
    createStoreWithRouter({
      routes,
      location,
      history: historyStub,
      passRouterStateToReducer
    }),
    applyMiddleware(
      routerMiddleware({ history: historyStub })
    )
  ];

  if (isLoop) {
    enhancers.push(install());
  }

  const store = createStore(
    isLoop ? combineReducers({
      stuff: state => state
    }) : reducer,
    initialState,
    compose(...enhancers)
  );

  return { store, historyStub };
};
github minedeljkovic / redux-elmish / examples / pair-of-counters / src / boilerplate.js View on Github external
export default (containerDomId, init, update, View) => {
  const initialState = toReduxLoop(init());
  function reducer(state, action) {
    if (action.type === '@@INIT') return state;
    return toReduxLoop(update(state, action));
  }

  const storeFactory = compose(
    install(),
    window.devToolsExtension ? window.devToolsExtension() : f => f
  )(createStore);

  const store = storeFactory(reducer, initialState);

  const ConnectedView = connect(appState => ({
    model: appState
  }))(View);

  render((
    
      
    
  ), document.getElementById(containerDomId));
}
github ChartIQ / finsemble-seed / src-built-in / components / UIAPI / store.js View on Github external
import { createStore } from "redux";
import rootReducer from "./reducers";
import { install } from "redux-loop";

export default createStore(rootReducer, undefined, install());
github mboperator / infinitely-composable-webapp-demo / src / index.js View on Github external
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore } from 'redux';
import { ModuleProvider } from 'redux-modules';
import { install, combineReducers } from 'redux-loop';
import { BrowserRouter as Router } from 'react-router-dom';

import './App.css';
import App from './App';
import './index.css';

const store = createStore(s => s, {}, install());

ReactDOM.render(
  
    <div style="{{">
      
        
      
    </div>
  ,
  document.getElementById('root'),
);