1/*
2* MyStore module
3*/
4
5import { createStore } from 'redux'
6
7// action creator
8export const setFoo = value => ({type: FOO, value: value})
9
10// init state
11const initState = {
12 foo: 'foo'
13}
14
15// reducer
16const reducer = (state = initState, action) => {
17 case FOO:
18 return { ...state, foo: action.value}
19 default:
20 return state
21}
22
23// create store
24export const store = createStore(reducer)
25
26
27/*
28* MyScreen client
29*/
30import { setFoo, store } from './MyStore'
31
32// selector
33const foo = store.getState().foo
34
35// dispatch
36store.dispatch(setFoo('bar')