export default function configureStore () {
  return applyMiddleware(
    thunkMiddleware,
    loggerMiddleware()
  )(createStore)
}
Example #2
0
import {applyMiddleware, createStore} from "redux"

import logger from "redux-logger"
import thunk from "redux-thunk"
import promise from "redux-promise-middleware"

import reducer from "./reducers"
import axios from 'axios'

const middleware = applyMiddleware(promise(), thunk, logger())

export default createStore(reducer, middleware)
Example #3
0
import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk'
import createLogger from 'redux-logger'
import rootReducer from '../reducers/root'

const logger = createLogger({ collapsed: true })
const createStoreWithMiddleware = applyMiddleware(
  thunkMiddleware,
  logger
)(createStore)

export default function configureStore() {
  const store = createStoreWithMiddleware(rootReducer)
  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
    module.hot.accept('../reducers', () => {
      const nextRootReducer = require('../reducers/index')
      store.replaceReducer(nextRootReducer)
    })
  }

  return store
}
Example #4
0
// This file merely configures the store for hot reloading.
// This boilerplate file is likely to be the same for each project that uses Redux.
// With Redux, the actual stores are in /reducers.

import { applyMiddleware, createStore } from 'redux';
import rootReducer from '../reducers';
import createLogger from 'redux-logger';

const logger = createLogger();

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


  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
    module.hot.accept('../reducers', () => {
      const nextReducer = rootReducer.default;
      store.replaceReducer(nextReducer);
    });
  }

  return store;
}

import { createStore, applyMiddleware, compose } from 'redux';
import { routerMiddleware } from 'react-router-redux';
import thunk from 'redux-thunk';
import createHistory from 'history/createBrowserHistory';
import createLogger from 'redux-logger';
import { persistState } from 'redux-devtools';
import rootReducer from '../reducers';
import DevTools from '../containers/DevTools';

const logger = createLogger({
  level: 'info',
  collapsed: true
});

const router = routerMiddleware(createHistory());

export default function configureStore(initialState) {
  const store = createStore(
    rootReducer,
    initialState,
    compose(
      applyMiddleware(thunk, router, logger),
      DevTools.instrument(),
      persistState(
        window.location.href.match(
          /[?&]debug_session=([^&]+)\b/
        )
      )
    )
  );
Example #6
0
import React, { Component } from 'react';
import {
  AppRegistry,
  Text,
  View
} from 'react-native';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import promise from 'redux-promise';
import createLogger from 'redux-logger';
import { Provider } from 'react-redux';
import { testReducer } from './Redux/reducers';
import HomeContainer from './Containers/HomeContainer';

let logger = createLogger();
let store = createStore(
    testReducer,
    applyMiddleware(thunk, promise, logger)
);

class setup extends Component {

    render() {
        return (
            <Provider store={store}>
                <HomeContainer />
            </Provider>
        );
    }
}
Example #7
0
/* global __DEVTOOLS__ */
import { createStore, applyMiddleware, compose } from 'redux';
import thunkMiddleware from 'redux-thunk';
import promiseMiddleware from 'redux-promise';
import createLogger from 'redux-logger';
import rootReducer from './reducers';
import { routerReducer, routerMiddleware } from 'react-router-redux';
import { browserHistory } from 'react-router';

const loggerMiddleware = createLogger({
  level: 'info',
  collapsed: true,
});

const masterReducer = (state = {}, action) => {
  let nextState = rootReducer(state, action);
  const nextRouting = routerReducer(state.routing, action);
  if (nextRouting !== nextState.routing) {
    nextState = {
      ...nextState,
      routing: nextRouting,
    };
  }
  return nextState;
};


let createStoreWithMiddleware;

const myMiddleware = [
  thunkMiddleware,
// Import default Styles
import '../styles/general/styles.scss';

// Import Modules
import React from 'react';
import ReactDOM from 'react-dom';
import createBrowserHistory from 'history/lib/createBrowserHistory'
import Router from 'react-router';
import routes from './routes';
import {initialise} from '../lib';
import createLogger from 'redux-logger';
import {Provider} from 'react-redux';

const history = createBrowserHistory();


const {store, modules, middlewares} = initialise([createLogger()]);

if (process.env.feature.DEV) {
  window.__STORE__ = store;
}

ReactDOM.render(
  <Provider store={store}>
    <Router history={history}
            routes={routes}/>
  </Provider>,
  document.getElementById('root')
);
Example #9
0
import React, {PropTypes} from 'react';
import { createStore, applyMiddleware, compose } from 'redux';
import { connect } from 'react-redux';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
import createLogger from 'redux-logger';
import Form from './components/Form';
import * as actions from './actions';
import store from './store';
import injectTapEventPlugin from 'react-tap-event-plugin';

injectTapEventPlugin();

const SmartForm = connect(state => state, actions)(Form);

const reduxMiddleware = applyMiddleware(thunk, createLogger());

export default props => (
	<Provider store={compose(reduxMiddleware)(createStore)(store)}>
		<SmartForm {...props}/>
	</Provider>
);

export {default as Text} from './components/Text';
export {default as SubmitButton} from './components/SubmitButton';
Example #10
0
import createLogger from 'redux-logger';

import {ActionTypes, ActionCreators} from './actions';
import * as config from './config';
import Ner from './containers'
import Cer from './reducers'


const logger = createLogger({
  collapsed: true,
  predicate: (getState, action) => config.debug && ((action.type !== ActionTypes.TIME_TICK) && (action.type !== ActionTypes.UPDATE_MOUSE_POS))
});

const e = {Ner: Ner,
			Cer: Cer,
			MW: logger,
			}


export default e
import reducers from './reducers';
import {apiErrorResponseMiddleware} from './api/apiErrorResponse.middleware';
import {analyticsMiddleware} from './analytics';

const middleware = [
  thunk,
  apiMiddleware,
  routerMiddleware(browserHistory),
  analyticsMiddleware,
  apiErrorResponseMiddleware
];
const storeEnhancers = [];

if (__DEBUG__) {
  let {persistState} = require('redux-devtools');
  middleware.push(createLogger());

  const getDebugSessionKey = () => {
    const matches = window.location.href.match(/[?&]debug_session=([^&#]+)\b/);
    return (matches && matches.length > 0) ? matches[1] : null;
  };

  Array.prototype.push.apply(storeEnhancers, [
    require('../widgets/devtools/devTools.component.js').instrument(),
    persistState(getDebugSessionKey(), (state) => fromJS(state))
  ]);
}

export default function configureStore() {
  const store = createStore(
    reducers,
Example #12
0
import 'babel-polyfill'
import React from 'react'
import { render } from 'react-dom'
import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import logger from 'redux-logger'
import thunk from 'redux-thunk'
import { Router, Route, hashHistory } from 'react-router'
import rootReducer from './reducers'
import App from './containers/App'
import AccountList from './containers/AccountList'
import { loadActive } from './actions/accounts'

const store = createStore(
  rootReducer,
  applyMiddleware(thunk, logger())
)

store.dispatch(loadActive())

render(
  <Provider store={store}>
      <Router history={hashHistory} >
        <Route path="/" component={App}>
          <Route path="/accounts" component={AccountList} />
        </Route>
      </Router>
  </Provider>,
  document.getElementById('root')
)
Example #13
0
export default function configureStore(options) {
  const {
    createEngine,
    initialState,
    platformDeps = {},
    platformMiddleware = []
  } = options;

  const engineKey = `redux-storage:${initialState.config.appName}`;
  const engine = createEngine && createEngine(engineKey);
  const firebase = new Firebase(initialState.config.firebaseUrl);
  // // Check whether connection works.
  // firebase.child('hello-world').set({
  //   createdAt: Firebase.ServerValue.TIMESTAMP
  // });

  const middleware = [
    ...platformMiddleware,
    injectMiddleware({
      ...platformDeps,
      engine,
      fetch: isomorphicFetch,
      firebase,
      getUid: () => shortid.generate(),
      now: () => Date.now(),
      validate
    }),
    promiseMiddleware({
      promiseTypeSuffixes: ['START', 'SUCCESS', 'ERROR']
    })
  ];

  if (engine) {
    let decoratedEngine = storageFilter(engine, [
      ['intl', 'currentLocale']
    ]);
    decoratedEngine = storageDebounce(decoratedEngine, 300);
    middleware.push(createStorageMiddleware(decoratedEngine, [], [
      SET_CURRENT_LOCALE
    ]));
  }

  // Logger must be the last middleware in chain.
  if (enableLogger) {
    const logger = createLogger({
      collapsed: true,
      // Convert immutable to JSON.
      stateTransformer: state => JSON.parse(JSON.stringify(state))
    });
    middleware.push(logger);
  }

  const store = createStore(
    resetOnLogout(appReducer, initialState),
    initialState,
    applyMiddleware(...middleware)
  );

  // Enable hot reload where available.
  if (module.hot) {
    // Enable Webpack hot module replacement for reducers.
    module.hot.accept('./app/reducer', () => {
      const nextAppReducer = require('./app/reducer');
      store.replaceReducer(resetOnLogout(nextAppReducer, initialState));
    });
  }

  return store;
}
import React from 'react'
import { render } from 'react-dom'
import { Router, browserHistory, Redirect } from 'react-router'
import useScroll from 'scroll-behavior/lib/useStandardScroll'
import { Provider } from 'react-redux'
import { createStore, applyMiddleware, combineReducers } from 'redux'
import thunk from 'redux-thunk'
import { syncHistoryWithStore, routerReducer } from 'react-router-redux'
import createLogger from 'redux-logger'
import routes from './src/routes'
import * as reducers from './src/reducers'
import * as actions from './src/actions'
import styles from './src/styles/'

const logger = createLogger({
  predicate: (getState, action) => action.type !== 'FETCHING'
})

const reducer = combineReducers({
  ...reducers,
  routing: routerReducer
})

const store = createStore(reducer, applyMiddleware(thunk, logger))
const scrollHistory = useScroll(() => browserHistory)()
const history = syncHistoryWithStore(scrollHistory, store)

render(
  <Provider store={store}>
    <Router history={history} routes={routes} />
  </Provider>,
import { applyMiddleware, compose, createStore } from 'redux'
import reducer from './reducer'
import logger from 'redux-logger'

let finalCreateStore = compose(applyMiddleware(logger()))(createStore)

export default function configureStore(initialState = { todos: [] }) {
	return finalCreateStore(reducer, initialState)
}
Example #16
0
import { persistStore, autoRehydrate } from 'redux-persist'
import { AsyncStorage } from 'react-native'
import createLogger from 'redux-logger'
import rootReducer, { persistentStoreBlacklist } from '../Reducers/'
import Config from '../Config/DebugSettings'
import sagaMiddleware from 'redux-saga'
import sagas from '../Sagas/'
import R from 'ramda'

// the logger master switch
const USE_LOGGING = Config.reduxLogging
// silence these saga-based messages
const BLACKLIST = ['EFFECT_TRIGGERED', 'EFFECT_RESOLVED', 'EFFECT_REJECTED']
// creat the logger
const logger = createLogger({
  predicate: (getState, { type }) => USE_LOGGING && R.not(R.contains(type, BLACKLIST))
})

// a function which can create our store and auto-persist the data
export default () => {
  const store = createStore(
    rootReducer,
    applyMiddleware(
      logger,
      sagaMiddleware(...sagas)
    ),
    (Config.reduxPersist) ? autoRehydrate() : null
  )

  if (Config.reduxPersist) {
    persistStore(store, {
Example #17
0
import React, { PropTypes } from 'react'
import ReactDOM from 'react-dom'
import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'
import createLogger from 'redux-logger'

import RootComponent from './components/root'
import rootReducer from './reducers/root'

const store = createStore(rootReducer, applyMiddleware(thunk, createLogger()))

const main = () => {
  ReactDOM.render(
    <Provider store={ store }>
      <RootComponent />
    </Provider>
  , document.getElementById('app'))

  setInterval(() => store.dispatch({type:'INCREMENT'}), 5000)
}

document.addEventListener('DOMContentLoaded', main)
Example #18
0
import React from 'react'
import { render } from 'react-dom'
import { createStore, applyMiddleware,compose } from 'redux'
import { Provider } from 'react-redux'
import logger from 'redux-logger'
import thunk from 'redux-thunk'
import reducer from './reducers'
import { getAllProducts } from './actions'
import App from './containers/App'

const middleware = process.env.NODE_ENV === 'production' ?
  [ thunk ] :
  [ thunk, logger() ]

const createStoreWithMiddleware = compose(applyMiddleware(...middleware),
    window.devToolsExtension ? window.devToolsExtension() : f => f)(createStore)
const store = createStoreWithMiddleware(reducer)

store.dispatch(getAllProducts())

render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('root')
)
Example #19
0
import { createStore, applyMiddleware } from 'redux';
import thunkMiddleware from 'redux-thunk';
import createLogger from 'redux-logger';
import MainAppReducer from '../reducers/reducers';

let loggerMiddleware = createLogger();

let store = createStore(
	MainAppReducer,
	applyMiddleware(
		thunkMiddleware,
		loggerMiddleware
	)
);

export default store;
Example #20
0
import {applyMiddleware, createStore} from "redux";
import reduxLogger from "redux-logger";
import reduxThunk from "redux-thunk"; //async stuff

import reducers from './reducers';

//middleware
const middleware = applyMiddleware(reduxThunk, reduxLogger());

export default createStore(reducers, middleware);
import { createStore, applyMiddleware, compose } from 'redux';
import logger from 'redux-logger';
import thunk from 'redux-thunk';
import reducers from './reducers';

const middleware = [thunk];
let devtools;

if (process.env.NODE_ENV === 'development') {
  // Add any middleware for dev environment only
  if (window.devToolsExtension) {
    devtools = window.devToolsExtension();
  } else {
    middleware.push(logger());
    devtools = f => f;
  }
} else {
  devtools = f => f;
}

export default createStore(
  reducers,
  compose(
    applyMiddleware(...middleware),
    devtools
  )
)
Example #22
0
import {createStore, applyMiddleware } from 'redux';
import rootReducer from './reducers/reducers';
import createLogger from 'redux-logger';
import thunkMiddleware from 'redux-thunk';
import {Iterable} from 'immutable';

const logger = createLogger({
    stateTransformer: (state) => {
        let newState = {};

        for (var i of Object.keys(state)) {
            if (Iterable.isIterable(state[i])) {
                newState[i] = state[i].toJS();
            } else {
                newState[i] = state[i];
            }
        };

        return newState;
    }
});
// const middlewares = [thunk];
// if (process.env.NODE_ENV === `development`) {
//     middlewares.push(logger);
// }
export default function configureStore() {
    const store =  createStore(rootReducer, applyMiddleware(thunkMiddleware, logger));

    //if (module.hot) {
    //    // Enable Webpack hot module replacement for reducers
    //    module.hot.accept('./reducers/reducerss', () => {
import {AsyncStorage} from 'react-native';
import {applyMiddleware, createStore, compose} from 'redux';
import {persistStore, autoRehydrate} from 'redux-persist';
import createLogger from 'redux-logger';
import ReduxPromise from 'redux-promise';
import thunkMiddleware from 'redux-thunk';
import Reactotron from 'reactotron';
import reducers from '../reducers';

// ativa o logger quando está em desenvolvimento
const isDebuggingInChrome = __DEV__ && !!window.navigator.userAgent;

// configura o logger middleware
const logger = createLogger({
  predicate: (getState, action) => isDebuggingInChrome,
  collapsed: true,
  duration: true,
});

// aplica os middlewares definidos no createStore
const createHBStore = applyMiddleware(
  thunkMiddleware,
  ReduxPromise,
  Reactotron.reduxMiddleware,
  logger
)(createStore);

/**
 * Configura o store para a aplicação
 * @param  {()=>} onComplete: função de callback chamada após a configuração
 * @return void
Example #24
0
} = window.__data;

import React from 'react';

import { createStore, combineReducers, applyMiddleware } from 'redux';

import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
import promise from './utils/redux/promiseMiddleware';
import createLogger from 'redux-logger';
import * as reducers from './reducers/';
import Editor from './containers/Editor';
import { editor } from './actions/';

let logger = createLogger({
  predicate: (getState, action) => rest.isDevelopment
});

const reducer = combineReducers(reducers);
const store = applyMiddleware(thunk, promise, logger)(createStore)(reducer)

store.dispatch(editor.switchApp(app));

const { url_params: { file } } = app;
if (file) {
  store.dispatch(editor.switchFile(file));
}

// Grande disablos for CodeMirror
window.onscroll = (e) => {
  window.scrollTo(0, 0);
Example #25
0
import React from 'react';
import ReactDOM from 'react-dom';
import styles from '../styles/style.scss';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import logger from 'redux-logger';
import rootReducer from './reducers';
import promise from 'redux-promise';
import App from './containers/App';

let store;

if (process.env.NODE_ENV !== 'production') {
  store = createStore(
    rootReducer, applyMiddleware(thunk, promise, logger())
  );

  module.hot.accept('./reducers', () => {
    const nextRootReducer = () => {
      require('./reducers/index');
      store.replaceReducer(nextRootReducer);
    }
  });

  // Hot module reloading:

  if (module.hot) {
    module.hot.accept();
  }
}
Example #26
0
import { createStore, applyMiddleware, compose } from 'redux'
import thunkMiddleware from 'redux-thunk'
import createLogger from 'redux-logger'

import DevTools from '../components/dev/DevTools'
import apiMiddleware from '../middlewares/api'
import reducer from '../reducers'


// store enhanvers
const enhancers = [
  applyMiddleware(
    thunkMiddleware,
    apiMiddleware,
    createLogger(),
  ),
  DevTools.instrument()
]

// get enhancer applied store factory
const finalCreateStore = compose(...enhancers)(createStore)


export default function configureStore(initialState) {
  const store = finalCreateStore(reducer, initialState)

  // hot reload reducers
  if (module.hot) {
    module.hot.accept('../reducers', () => {
      return store.replaceReducer(require('../reducers'))
    })
Example #27
0
import { applyMiddleware, createStore } from "redux";

import logger from "redux-logger";
import thunk from "redux-thunk";

import reducer from "./reducers";

const middleware = applyMiddleware(thunk, logger());

export default createStore(reducer, middleware)
Example #28
0
import { applyMiddleware, compose, createStore } from 'redux';
import reducer from '../reducers/reducers';
import logger from 'redux-logger';
let finalCreateStore = compose(
    applyMiddleware(logger())
)(createStore);

export default function configStore(initialState = { todos: [] }){
    return finalCreateStore(reducer, initialState)
}
Example #29
0
/***
 * Configures and returns the Store with the root reducer and middleware
 */

// Do this once before any other code in your app (http://redux.js.org/docs/advanced/AsyncActions.html)
import 'babel-polyfill'
import thunkMiddleware from 'redux-thunk'
import createLogger from 'redux-logger'
import { createStore, applyMiddleware, compose } from 'redux'
import React from 'react'
import rootReducer from './reducers/reducer'
import {Map} from 'immutable';

// Create a logger
const loggerMiddleware = createLogger()

// Create the store applying our reducer and the thunk and logger middleware
export default function makeStore(initialState=Map()) {
    return createStore(
        rootReducer,
        initialState,
        compose(
            applyMiddleware(
                thunkMiddleware, // lets us dispatch() functions
                loggerMiddleware // neat middleware that logs actions
            ),
            // Use the Chrom devToolsExtension
            window.devToolsExtension ? window.devToolsExtension() : f => f
        )
    )
Example #30
0
import { applyMiddleware, compose, createStore } from 'redux'
import { combineReducers } from 'redux-immutable'
import createLogger from 'redux-logger'
import thunk from 'redux-thunk'

import { batchedSubscribe } from 'redux-batched-subscribe'
import coins from 'ducks/coins'
import game, { actionTypes as gameActionTypes } from 'ducks/game'
import machines from 'ducks/machines'

const logger = createLogger({
  level: 'warn',
  stateTransformer: (state) => state.toJS(),
  predicate: (getState, action) => action.type !== gameActionTypes.TICK,
})

const reducer = combineReducers({ coins, game, machines })

const rafSubscriber = batchedSubscribe(notify => {
  requestAnimationFrame(() => {
    notify()
  })
})

const enhancer = compose(
  applyMiddleware(thunk /*, logger */),
  rafSubscriber
)
const store = createStore(reducer, enhancer)

export default store