Exemplo n.º 1
0
export default () => {
  const debounceConfig = { filter: 300 };
  const debouncer = createDebounce(debounceConfig);
  const reducer = combineReducers({
    groups: groupsStore.reducer,
  });
  const store = createStore(reducer, applyMiddleware(debouncer, testDataMiddleware));
  const actions = {
    groups: bindActionCreators(groupsStore.actions, store.dispatch),
  };

  return { store, actions };
};
export function createNewStore() {
  const initialState = new Map({});

  const sagaMiddleware = createSagaMiddleware();
  const store = createStore(rootReducer, initialState, compose(
    applyMiddleware(
      createDebounce({ simple: 1000 }),
      createLogger({
        stateTransformer: state => state.toJS ? state.toJS() : state,
        actionTransformer: action => (action.payload && action.payload.toJS) ? action.payload.toJS() : action
      }),
      sagaMiddleware
    ),
    typeof window === 'object' && typeof window.devToolsExtension !== 'undefined' ? window.devToolsExtension() : f => f
  ));
  sagaMiddleware.run(rootSaga);
  return store;
};
Exemplo n.º 3
0
import createDebounce from 'redux-debounce'
import createThrottle from 'redux-throttle'
import { hashHistory } from 'react-router'
import { enableBatching } from 'redux-batched-actions'
import { routerMiddleware } from 'react-router-redux'
import rootReducer from '../reducers'

const router = routerMiddleware(hashHistory)
const gather = createGather()
const throttle = createThrottle()
const logger = createLogger({
  collapsed: true
})
const debounce = createDebounce({
  wait: 200,
  trailing: true,
  leading: false
})

let enhancer

if (process.env.NODE_ENV === 'production') {
  enhancer = compose(applyMiddleware(
    thunk,
    gather,
    debounce,
    throttle,
    router,
  ))
} else {
  enhancer = compose(applyMiddleware(