I have product
, which are tied comments
, attachments
, images
. All of these items are taken from the repository ngrx
, which means that all of these items are observable. My question is: how do I combine these elements?
I usually use:
combineLatest(selectProducts, selectProductComments, (products, comments) => {
})
However, it combineLatest
works with 2 sets of observables and I have 4 of them. So what is the easiest way to do this?
Here is the context:
So, we show the list products
when each product is clicked, product information is downloaded and displayed in a pop-up window. This information contains comments
, attachments
and images
. This step can be called the phase DEEP_LOADING
where, when the user clicks on products, comments, attachments and images are downloaded via http.
The user can also add new images, comments or attachments. When he does, he is added to the list of comments comment
with the status pending
set to true. When the HTTP request resolves, this comment
wait property is set to false.
, comments
, attachments
images
. , , comments
- , ( ), , .
: ( , , , ..)
export function commentReducer(state, action) {
switch (action.type) {
case 'SET_COMMENT':
const newState = state.filter((c: AppComment) => c.pending);
newState.push(action.payload);
return newState;
case 'CLEAR':
return initialState;
}
}