-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore.js
More file actions
49 lines (41 loc) · 1.41 KB
/
store.js
File metadata and controls
49 lines (41 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { createStore, compose, applyMiddleware } from "redux";
import { reactReduxFirebase } from "react-redux-firebase";
import { AsyncStorage } from "react-native";
import thunkMiddleware from "redux-thunk";
import AppReducer from "./app-reducer";
import firebase from "firebase";
import ApiKeys from "./constants/ApiKeys";
// Initialize firebase...
if (!firebase.apps.length) {
firebase.initializeApp(ApiKeys.FirebaseConfig);
}
export const profilePopulates = [{ child: "role", root: "roles" }];
const rrConfig = {
userProfile: "profiles",
profileParamsToPopulate: profilePopulates, // populate list of todos from todos ref
enableLogging: true,
ReactNative: { AsyncStorage },
attachAuthIsReady: true, // attaches auth is ready promise to store
firebaseStateName: "firebase", // should match the reducer name ('firebase' is default)
enableRedirectHandling: false // since react-native does not support http or https and isn't a browser
};
export default function configureStore(initialState, history) {
const store = createStore(
AppReducer,
initialState,
compose(
reactReduxFirebase(firebase, rrConfig),
applyMiddleware(
thunkMiddleware
//loggerMiddleware
)
)
);
if (module.hot) {
module.hot.accept("./app-reducer", () => {
const nextAppReducer = require("./app-reducer");
store.replaceReducer(nextAppReducer);
});
}
return store;
}