I am trying to create a master/detail page and I need the master id to retrieve the related records of the detail list.
I have a selector
export const selectRecords= (state: CoreState) => state.records;
export const getId = createSelector(selectRecords,
(state: myState) => state && state.selectedRecords && state.selectedRecords.id
);
and in my effect I am trying to get the latest id from the store with something like:
@Effect()
getSomething$ = this.actions$.pipe(
ofType<GetMyRecords>(MyType.GET_RECORDS),
withLatestFrom(this.store.select(getId)),
switchMap(([action, id]) => {
this.log.debug('Get ID', id);
... calling my service here
})
);
but even while I am using withLatestFrom, what I am getting is the previous ID and not the latest.
When I am checking the console from Redux, the selectedRecords.id in the state is the correct one (the latest), the one I would like to retrieve.
I know it's a longshot, but does anyone have a tip or advice what I could try to get the correct last id from the store?