Search code examples
angularngrx

Selector don't get the object, even if I see it on redux


I don't know why but my second selector not working. But I verified, everything is the same but for another object. And all my object exist when I look on the redux tool

// selector not working
this.myActivityLike$ = this.store$.pipe(
  select(ActivityFeatureStoreSelectors.selectAllActivityLikeFeatureItems),
  filter(value => value !== undefined),
  tap(list => console.log(list))
)
// selector working
this.piins$ = this.store$.pipe(
  select(PiinsFeatureStoreSelectors.selectAllPiinsFeatureItems),
  filter(value => value !== undefined),
  tap(list => console.log(list))
);

And this is my selector :

export const selectAllActivityLikeFeatureState: MemoizedSelector<
  object,
  State
> = createFeatureSelector<State>('activityLikeFeature');

export const selectAllActivityLikeFeatureItems: (
  state: object
) => LikeActivityModel[] = featureAdapter.getSelectors(selectAllActivityLikeFeatureState).selectAll;

Thank you if you can found the solution


Solution

  • I founded the solution! If someone is in my situation we have two ways to show a selector (maybe more..). Either you can show in the html with a NgFor Async. Or you can use the subscribe. Subscribe is better if you want to recycle your data in the component