I wonder where is a good place to transform a response entity(ies) before it is set in my Redux state.
Example
chat_message
entityread
boolean property sent by the serverunread
boolean property = !message.read && message.user_id !== currentUser.id
Questions
getChatMessages
selector (reselect
)?Component
, but this (simple) logic is not shared and duplicated all over the place...unread
attribute from the server...Notes
unread
attribute example is a simplified example.isMessageUnread
helper function shared by getLastChatMessage
, getChatMessages
selectors. I also don't like selectors doing too much logic.unread
attribute is computed only when receiving response.reducers
is not a good place to do this tranformations. Might be easy for simple entities, but what about "heavy" transformation (iterating over collections, checking relationships, etc) ? I would prefer to put that new logic outside of: selectors, reducers, and entities. Kinda like a normalizr "plugin" / interceptor / transformer / post-processor...Normalizr provides the processStrategy
option:
Strategy to use when pre-processing the entity. Use this method to add extra data, defaults, and/or completely change the entity before normalization is complete.