Skip to content

Instantly share code, notes, and snippets.

@vzaidman
Created October 8, 2017 04:22
Show Gist options
  • Save vzaidman/4310a3ef09e9a8a66c0c608945930360 to your computer and use it in GitHub Desktop.
Save vzaidman/4310a3ef09e9a8a66c0c608945930360 to your computer and use it in GitHub Desktop.
import {composeReducers, makeReducer, makeAsyncReducer} from 'redux-toolbelt'
import { loadCustomers, loadOrders, loadProfile, changeUserName, logout } from './actions'
export default composeReducers(
{
profile: makeAsyncReducer(loadProfile),
customers: makeAsyncReducer(loadCustomers),
orders: makeAsyncReducer(loadOrders)
},
makeReducer(logout, (state, {type, payload}) => ({
...state,
profile: { loading: false, data: null },
customers: { loading: false, data: null },
orders: { loading: false, data: null }
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment