fb-test-module
Version:
How to use: ``` import {store, getStore} from 'fb-test-module'; conf.DialogramApi = "API_BASE_URL"; conf.Platform = "mobile"; //use "web" if you are on webApp getStore(); //Inject store in your provider ``` and you'r readyt to go. # Base ## Act
78 lines (60 loc) • 1.98 kB
text/typescript
//https://github.com/nearform/react-redux-typescript-saga-immutable/blob/master/src/store.ts
/*
import { combineReducers, createStore, applyMiddleware, compose } from 'redux';
import { persistReducer, persistStore } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import immutableTransform from 'redux-persist-transform-immutable';
import createSagaMiddleware from 'redux-saga';
import {rootSaga} from './saga';
import { sessionReducer } from './Session/Reducer';
import { videoReducer } from './Videos/Reducer';
import { userReducer } from './User/Reducer';
import {conf} from './Config';
const sagaMiddleware = createSagaMiddleware();
const reducer = combineReducers({
session: sessionReducer,
videos: videoReducer,
user: userReducer,
});
const persistConfig = {
key: 'root',
storage,
transforms: [immutableTransform()],
whitelist: [
'session',
'user'
],
};
const persistedReducer = persistReducer(persistConfig, reducer);
const middlewares = [sagaMiddleware];
const composeEnhancers = window['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__'] as typeof compose || compose;
const store = createStore(
persistedReducer,
composeEnhancers(applyMiddleware(...middlewares))
);
sagaMiddleware.run(rootSaga);
export const loadPersistStore = (cb) => {
return persistStore(store, null, cb);
};
export default store;*/
import { nativeStore } from './store.native';
import { webStore } from './store.web';
import { persistStore } from 'redux-persist';
import { conf } from './Config';
let store;
let loadPersistStore;
function getStore() {
if (conf.Platform === "mobile") {
store = nativeStore();
} else {
store = webStore();
//loadPersistStore = webLoadPersistStore;
}
}
const LoadPersistStore = (cb) => {
return persistStore(store, null, cb);
}
export {
store,
LoadPersistStore, getStore
};