Created
December 8, 2017 12:42
-
-
Save vzaidman/b0d233163534d3e68562cb0074a68edd to your computer and use it in GitHub Desktop.
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 { ordersReducer } from './oreders-reducer' | |
import { fetchOrders, addOrder, updateOrder, fetchProfile } from './actions' | |
import { getState, dispatch } from './store' | |
dispatch({ TYPE: '@@INIT' }) | |
console.log(getState()) | |
// the initial state is { data: [], loading: false } | |
// when we dispatch the "fetchOrders" action, an api call to fetch orders is made | |
// the state becomes { data: [], loading: true } | |
await dispatch(fetchOrders()) | |
// then, when the fetching ends | |
console.log(getState()) | |
// the state becomes { data: ['order1', 'order2'], loading: false } | |
// later, when we logout: | |
await dispatch(logout()) | |
console.log(getState()) | |
// { data: undefined, loading: false } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment