Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NGRX-Entity-Relationship Graph do not receive the selector #796

Open
raalarcon9705 opened this issue Jul 20, 2021 · 1 comment
Open

NGRX-Entity-Relationship Graph do not receive the selector #796

raalarcon9705 opened this issue Jul 20, 2021 · 1 comment

Comments

@raalarcon9705
Copy link

I am using ngrx-entity-relationship in my angular project with @ngrx/store.

When I try to use reduceGraph inside an effect, no change occurs in the store, and when I check the devtool I see that the selector is not reaching

this is the effect code

loadPostById$ = createEffect(() =>
    this.actions$.pipe(
      ofType(PostActions.loadPostById),
      concatMap(({ id }) =>
        this.postService.loadPostById(id).pipe(
          map((post) => reduceGraph({
            data: post,
            selector: rootPost()
          })),
          catchError((error) => of(PostActions.loadPostByIdFailure({ error })))
        )
      )
    )
  );

this is the relationships code


export const rootPost = rootEntitySelector(fromPosts.selectPostsState);
export const relPostUser = relatedEntitySelector(
  fromUsers.selectUsersState,
  'publisherId',
  'publisher'
)

This is what i see in devtool, it has no selector this is what i see in the devtool

image

@satanTime
Copy link
Owner

Hi @raalarcon9705,

thank you for the feedback.

The case looks good so far. Might you debug it with tap operator?

loadPostById$ = createEffect(() =>
    this.actions$.pipe(
      ofType(PostActions.loadPostById),
      concatMap(({ id }) =>
        this.postService.loadPostById(id).pipe(
          map((post) => reduceGraph({
            data: post,
            selector: rootPost()
          })),

          // add it here
          tap(console.log),

          catchError((error) => of(PostActions.loadPostByIdFailure({ error })))
        )
      )
    )
  );

Also to make this action working, a meta reducer should be connected: https://ngrx-entity-relationship.sudo.eu/normalization/reducer#ngrx.
Might you confirm this setting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants