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
76 lines (62 loc) • 2.23 kB
JavaScript
//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;*/
Object.defineProperty(exports, "__esModule", { value: true });
const store_native_1 = require("./store.native");
const store_web_1 = require("./store.web");
const redux_persist_1 = require("redux-persist");
const Config_1 = require("./Config");
let store;
exports.store = store;
let loadPersistStore;
function getStore() {
if (Config_1.conf.Platform === "mobile") {
exports.store = store = store_native_1.nativeStore();
}
else {
exports.store = store = store_web_1.webStore();
//loadPersistStore = webLoadPersistStore;
}
}
exports.getStore = getStore;
const LoadPersistStore = (cb) => {
return redux_persist_1.persistStore(store, null, cb);
};
exports.LoadPersistStore = LoadPersistStore;
;