[ X ] Bug report
When inheriting from a Parent @State class with a @Selector, using that selector on child @State class doesnt return the store value
Child @State should return the value of the selected value via the @Selector method in its parent class
https://stackblitz.com/edit/ngxs-inherit-selector-issue-1108
N/A
Libs:
N/A
Browser:
N/A
For Tooling issues:
N/A
Others:
N/A
One thing i noticed is that if i add the parent @State to the AppModule it works, but the behavior is not the desired. In this case both parent and child state have the same state.
I wonder if i what i want to do is possible or not…
I'm sorry, maybe I'm missing something, but what behavior do you expect if you don't add the CountState when calling forRoot? We can't manually add this state to the root DI providers.
The behaviour expected is to able to inherit selectors from base abstract classes, to avoid duplicated selectors, for instance for "loading" @selector
Yes, I noticed this problem and it needs to be solved
@joaqcid
You use a selector from the non-imported class:
@Select(CountState.count) count$: Observable<number>;
yeah, i think i was testing with both states, just updated it, you can see it doesnt work, even if use ChildCountState.count
You could just write ChildCountState except of CountState cause I got confused haha :joy:
@arturovt Hi,
Is it going to be resolved? If yes then please mark it as bug or feature as you see it. So we can follow this.
Thanks
Hi!
After reading more the documentation, found i can actually do this with dynamic selectors
export abstract class CountState {
static get count() {
return createSelector([this], (state: CountStateModel) => {
return state.count
})
}
}
Updated the stackblitz with working code
You can send us a pull request for updating documentation.
@joaqcid we can close?
yup
Most helpful comment
@joaqcid we can close?