My question relates to ngrx effects and reducers.
I need to transform data retrieved from the backend before putting it into the ngrx store. The data retrieved from the backend is an plain array of Message
(Message
is a custom type in my application):
Message[]
I need to transform the array into the following:
Map<string, Message[]>
Basically I am grouping a user's messages by the counterparty (recipient or sender) ID (the key).
I am not sure where to perform the transformation from Message[]
to Map<string, Message[]>
: should I put the transformation business logic into the @Effect or into the reducer function?