Created
October 8, 2017 04:19
-
-
Save vzaidman/2c9bb5d2a9ee8cbe76842b49942e0deb to your computer and use it in GitHub Desktop.
This file contains 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 {composeReducers, makeReducer, makeAsyncReducer} from 'redux-toolbelt' | |
import { updateObjectProperties } from 'redux-toolbelt-immutable-helpers' | |
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}) => | |
updateObjectProperties( | |
state, | |
['profile', 'customers', 'orders'], | |
{loading: false, data: null} | |
) | |
) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment