I have an issue with the NGXS Selector.
In my state, I call an API to get a table. Because of unified error handling, I first call the API and then defer the actual handling of the request to a service made for store management like:
@Action(LoadTable)
private loadTable(ctx: StateContext<SomeState>) {
const state = ctx.getState();
ctx.patchState({
table: {
...state.table,
content: emptyTable,
loading: true
}
});
return this.api.loadTable()
.pipe(StateUtilService.errorHandlingOperator<SomeState>(
ctx,
'table',
TransformService.tableTransformCallback()
);
}
In my error handling operator, I pass in the store to be able to patch it, then check whether a variable with the according name and type 'table' exists and finally pass the returned data through the tableTransformCallback function and save the result via ctx.patchState().
In my selector, I return the contents of the table plain and simple without any additional transformations.
The problem is, that the table loads and ALL of its properties get updated except one. The parameter totalNumberOfRows stays 0, taken from the original emptyTable object I use when loading (or reloading) the table. When I check the store, it correctly shows the API-loaded number of rows, but the selector ignores the correct value, not passing it through. It messes up the paginator.
What could be the issue here?