Skip to content

Filter entities with store property #436

Answered by Foprta
Foprta asked this question in Q&A
Discussion options

You must be logged in to vote

Forgot to mention there was a joinRequestResult operator and i was confused on how to filter its result, as it has addittional fields. But then i realised i can filter entites BEFORE joinRequestResult operator.

Ended up with this solution

  readonly entities$ = combineLatest([
    store
      .combine({
        entities: store.pipe(selectAllEntities()),
        UIEntities: store.pipe(selectEntities({ ref: UIEntitiesRef })),
      })
      .pipe(unionEntities(idKey)),

    store.pipe(select((state) => state.filter)),
  ]).pipe(
    map(([entities, filter]) => entities.filter(({ Country }) => Country.includes(filter))),
    joinRequestResult([STORE_NAME]),
    shareReplay(1),
  );

Thanks f…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Foprta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants