Skip to content

Instantly share code, notes, and snippets.

@vzaidman
Created October 8, 2017 04:19
Show Gist options
  • Save vzaidman/2c9bb5d2a9ee8cbe76842b49942e0deb to your computer and use it in GitHub Desktop.
Save vzaidman/2c9bb5d2a9ee8cbe76842b49942e0deb to your computer and use it in GitHub Desktop.
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