The Redux Team suggests selectors always return Immutable.JS objects .However, I find it's difficult for selectors to return Immutable.JS objects when selectors' returning objects are constructed by multiple slices of the state.
Take the official shopping-cart demo as an example. The selector getCartProducts
uses both the cart slice and the product slice of the state to construct the returning object:
export const getCartProducts = state =>
getAddedIds(state).map(id => ({
...getProduct(state, id),
quantity: getQuantity(state, id)
}))
In this case, if using Immutable.JS, how to reconstruct this selector to let it return a Immutable.JS object?