-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (26 loc) · 850 Bytes
/
index.js
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
import {createStore} from 'redux'
import {initialState, reducer} from 'store'
import {compose, filter, map} from 'ramda'
import localStorage from 'effects/localStorage'
import log from 'effects/log'
import resize from 'effects/resize'
import seed from 'effects/seed'
import setup from 'effects/setup'
import view from 'effects/view'
const store = createStore(reducer, initialState)
const push = store.dispatch
const effects = [localStorage, log, resize, seed, setup, view]
const listeners = compose(
filter((listener) => listener != null),
map((effect) => effect(push)),
)(effects)
let prevState
store.subscribe(
() => {
if (prevState !== store.getState()) {
listeners.forEach((listener) => listener(store.getState()))
prevState = store.getState()
}
}
)
listeners.forEach((listener) => listener(store.getState()))