Question: 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**?

Answer: 
The way i do it is to fetch and transform data in a service just like in the old days.

Effects react to an action and make the call through the service to get the data back and dispatch other actions based on the responses it receives.

This makes testing much easier since the service is kept separate from the effect which main purpose is to react on a certain action, not packaging data.

Reducer can be used for this but again you should keep it clean for readability purposes
My opinions: 

1. Data retrieved from backend will be kept unchanged in the store.
2. Using selectors as your business logic (combine, transform and etc.) for the dumb components.
3. Maybe the only transformation is to use normalizr to flat the data.