Skip to content

Component Store support for ACTIONS #4220

Closed Answered by vaidehi-cell
vaidehi-cell asked this question in Q&A
Discussion options

You must be logged in to vote

I figured out a case where in using actions in component store can cause an issue.
Consider the following scenario:
ParentComponent:

@for (item of items) {
<app-item [item]=item></app-item>
}

And the ChildComponent requires to have a store and get data of subItem using a service call.
We write effects listening to get action in the ChildComponent's component store as follows:

readonly getSubItem = this.componentStore.effect(() =>
        this.actions$.pipe(
            ofType(ItemActions.GET_SUBITEM),
            mergeMap((action) => this.service.getSubItem(action.subItemId).pipe(
                tapResponse(
                    (response) => {
                        const subItem: SubItem 

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@david-shortman
Comment options

Answer selected by vaidehi-cell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants