-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathramen-state.html
36 lines (35 loc) · 1.2 KB
/
ramen-state.html
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
<script src="../redux.min/index.js" type="text/javascript" async onload="dependencyCompleted()"></script>
<link rel="import" href="../polymer-redux/polymer-redux.html">
<script type="text/javascript">
window.ramen = {};
if(!window.config || !window.config.initialState){
window.ramen.initialState = {
authorization: {
user: {},
token: "",
isLoggedIn: false
},
config: {
environment: "development"
}
}
}else{
window.ramen.initialState = window.config.initialState;
}
window.ramen.currentState = window.ramen.initialState;
window.ramen.reducer = (state, action) => {
if(!window.config || !window.config.reducer){
if(!state) return window.ramen.initialState;
switch (action.type){
default:
return state;
}
}else{
return window.config.reducer(state, action);
}
}
let dependencyCompleted = (e) => {
window.ramen.store = Redux.createStore(window.ramen.reducer);
window.ramen.stateMixin = PolymerRedux(window.ramen.store);
}
</script>