Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { NativeModules } from 'react-native'
let createStore = reduxCreateStore
let sagaMiddlewarePlugins
if (global.__DEV__) {
const scriptURL = NativeModules.SourceCode.scriptURL
const scriptHostname = scriptURL.split('://')[1].split(':')[0]
Reactotron.configure({ name: 'uPortMobile', host: scriptHostname })
.useReactNative()
.use(sagaPlugin())
.use(reactotronRedux())
.connect()
.clear()
const sagaMonitor = Reactotron.createSagaMonitor()
sagaMiddlewarePlugins = { sagaMonitor }
createStore = Reactotron.createStore
console.tron = Reactotron
}
// const logMiddleware = (store) => (next) => (action) => {
// console.log(action.type)
// return next(action)
// }
let composeEnhancers
if (typeof window !== 'undefined') {
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
} else {
composeEnhancers = compose
}
auth,
devices,
lockedAttributes,
login,
orientation,
resources,
selectedAttributes,
selectedDevice,
selectedResource,
streaming,
toast,
userDevices,
});
// Saga middleware
const sagaMonitor = Config.useReactotron ? Reactotron.createSagaMonitor() : null;
const sagaMiddleware = createSagaMiddleware({ sagaMonitor });
const middleware = [thunkMiddleware, vibrate, sagaMiddleware];
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
// If Reactotron is enabled (default for dev), we'll create the store through Reactotron
const createAppropriateStore = Config.useReactotron ? Reactotron.createStore : createStore;
const store = createAppropriateStore(reducer, composeEnhancers(applyMiddleware(...middleware)));
// Kick off root saga
store.sagaTask = sagaMiddleware.run(rootSaga);
const persistor = persistStore(store);
// For purge the Store
// persistor.purge();
export default () => {
Reactotron.createSagaMonitor()
const store = createStore(
rootReducer,
compose(
middleware,
Reactotron.createEnhancer()
)
)
// const store = (Reactotron as any).createStore(rootReducer, compose(middleware))
return store
}
import Reactotron from 'reactotron-react-native';
import createSagaMiddleware from 'redux-saga';
import applyAppStateListener from 'redux-enhancer-react-native-appstate';
import reducers from '../reducers';
import sagas from '../sagas';
const createStore = __DEV__ ? Reactotron.createStore : reduxCreateStore;
let sagaMiddleware;
let enhancers;
if (__DEV__) {
/* eslint-disable global-require */
const reduxImmutableStateInvariant = require('redux-immutable-state-invariant').default();
sagaMiddleware = createSagaMiddleware({
sagaMonitor: Reactotron.createSagaMonitor()
});
enhancers = compose(
applyAppStateListener(),
applyMiddleware(reduxImmutableStateInvariant),
applyMiddleware(sagaMiddleware)
);
} else {
sagaMiddleware = createSagaMiddleware();
enhancers = compose(
applyAppStateListener(),
applyMiddleware(sagaMiddleware)
);
}
const store = createStore(reducers, enhancers);
export default initializeStore = () => {
// create the store
if (__DEV__) {
// reactotron development mode
const sagaMonitor = Reactotron.createSagaMonitor();
var sagaMiddleware = createSagaMiddleware({sagaMonitor});
const middlewares = applyMiddleware(
thunk,
sagaMiddleware
);
const enhancers = compose(middlewares, autoRehydrate());
var store = Reactotron.createStore(reducers, enhancers);
} else {
// release mode
var sagaMiddleware = createSagaMiddleware();
const middlewares = applyMiddleware(
thunk,
sagaMiddleware
);
const enhancers = compose(middlewares, autoRehydrate());
var store = createStore(reducers, enhancers);
export default initializeStore = () => {
// create the store
if (__DEV__) {
// reactotron development mode
const sagaMonitor = Reactotron.createSagaMonitor();
var sagaMiddleware = createSagaMiddleware({sagaMonitor});
const middlewares = applyMiddleware(
thunk,
sagaMiddleware
);
const enhancers = compose(middlewares, autoRehydrate());
var store = Reactotron.createStore(reducers, enhancers);
} else {
// release mode
var sagaMiddleware = createSagaMiddleware();
const middlewares = applyMiddleware(
thunk,
sagaMiddleware
);
const enhancers = compose(middlewares, autoRehydrate());
var store = createStore(reducers, enhancers);
export default (rootReducer: Reducer, rootSaga: () => SagaIterator) => {
/* ------------- Redux Configuration ------------- */
const middleware = [];
const enhancers = [];
/* ------------- Analytics Middleware ------------- */
if (Config.useReactotron) {
middleware.push(ScreenTracking);
}
/* ------------- Saga Middleware ------------- */
let opts = {};
if (Config.useReactotron) {
const sagaMonitor: Monitor = Reactotron.createSagaMonitor();
opts = { sagaMonitor };
}
const sagaMiddleware = sagaMiddlewareFactory(opts);
middleware.push(sagaMiddleware);
/* ------------- Assemble Middleware ------------- */
enhancers.push(applyMiddleware(...middleware));
// if Reactotron is enabled (default for __DEV__), we'll create the store through Reactotron
const createAppropriateStore = Config.useReactotron ? Reactotron.createStore : createStore;
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createAppropriateStore(rootReducer, composeEnhancers(...enhancers));
import {createStore, applyMiddleware} from 'redux';
import Reactotron from 'reactotron-react-native';
import createSagaMiddleware from 'redux-saga';
import reducers from './reducers';
import rootSaga from './sagas';
/**
* Reactotron linking for Redux-Saga.
*/
const sagaMonitor = Reactotron.createSagaMonitor();
const sagaMiddleware = createSagaMiddleware({sagaMonitor});
/**
* Redux store creation.
*/
const store = Reactotron.createStore(
reducers,
applyMiddleware(sagaMiddleware)
);
/**
* Starts root saga listener.
*/
sagaMiddleware.run(rootSaga);
export default store;
export default function configureStore() {
const sagaMiddleware = createSagaMiddleware({
sagaMonitor: Reactotron.createSagaMonitor(),
});
const persistedReducer = persistReducer(
{
key: 'root',
storage: AsyncStorage,
whitelist: ['auth'],
debug: true,
},
rootReducer
);
const store = Reactotron.createStore(
persistedReducer,
compose(applyMiddleware(sagaMiddleware, logger))
);
export default () => {
const sagaMonitor = DebugConfig.useReactotron
? Reactotron.createSagaMonitor()
: undefined
const sagaMiddleware = createSagaMiddleware({ sagaMonitor })
const createAppropriateStore = DebugConfig.useReactotron
? Reactotron.createStore
: createStore
const store = createAppropriateStore(
persistedReducer,
applyMiddleware(sagaMiddleware)
)
const bootstrappedCallback = () => store.dispatch(StartupActions.startup())
const persistor = persistStore(store, undefined, bootstrappedCallback)
sagaMiddleware.run(rootSaga)