Reputation: 616
I'm using Angular 17 with Ngrx
I have a details page protected by a Guard that checks if the element exists in the store or explicitly dispatches a 'get by id' action.
/**
* check Store Function
* @param requestId Request ID
*/
checkStore(requestId: string): Observable<boolean> {
this.store.dispatch(
RequestLifeCycleActions.LoadRequestLifeCycle({
action: RequestQueryActions.REQUESTS,
requestId,
})
);
return this.store.select(requestLifeCycleSelectors.selectIfRequestLifeCycleListLoaded).pipe(
filter((loaded) => loaded),
take(1)
);
}
Sometimes, when accessing the page multiple times (for example, selecting one element, then going back, and then selecting another one), it may result in a "Cannot read properties of null (reading 'destroyed')" error with no content appearing, even though the data is successfully loaded in the store.
I tried disabling the guard and dispatching directly without a check from the page component itself, but I still receive the same behavior.
Upvotes: 0
Views: 85