This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createStore, applyMiddleware, compose } from 'redux' | |
| import thunk from 'redux-thunk' | |
| import api from '../middleware/api' | |
| import rootReducer from '../reducers' | |
| import DevTools from '../containers/DevTools' | |
| const store = (preloadedState) => { | |
| return createStore( | |
| rootReducer, | |
| preloadedState, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const store = new Redux.Store({ | |
| initialState: {}, | |
| reducers: { count }, | |
| middlewares: [api, devTools], | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const increment = (count) => ({ type: 'INCREMENT', payload: count }) | |
| const decrement = (count) => ({ type: 'DECREMENT', payload: count }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const countReducer = (state, action) => { | |
| switch(action.type) { | |
| case INCREMENT: | |
| return state + action.payload | |
| case DECREMENT: | |
| return state - action.payload | |
| default: | |
| return state | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const countReducer = { | |
| INCREMENT: (state, action) => state + action.payload, | |
| DECREMENT: (state, action) => state - action.payload, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const incrementAsync = (count) => async (dispatch) => { | |
| await delay() | |
| dispatch(increment(count)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const incrementAsync = async (count) => { | |
| await delay() | |
| dispatch(increment(count)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const count = { | |
| state: 0, | |
| reducers: { | |
| increment: (state, action) => state + action.payload, | |
| decrement: (state, action) => state - action.payload, | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const anyActionCreator = (namespace, type) => (payload) => ({ | |
| type: `${namespace}/${type}`, | |
| payload | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { init, dispatch } from '@rematch/core' | |
| import delay from './makeMeWait.js' | |
| const count = { | |
| state: 0, | |
| reducers: { | |
| increment: (state, payload) => state + payload, | |
| decrement: (state, payload) => state - payload, | |
| }, | |
| effects: { |