Store: Selectors should not have a specific order in a query class

Created on 2 Jul 2019  路  6Comments  路  Source: ngxs/store

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => https://github.com/ngxs/store/blob/master/CONTRIBUTING.md
[ ] Other... Please describe:

Current behavior


A selector should be declared after it's dependencies in a query class.

Expected behavior


Any developer-preferred selectors order.
Or an exception or, at least, a warning in the console that indicates that there is an issue with a hint on how to fix it.

Minimal reproduction of the problem with instructions


https://stackblitz.com/edit/angular-qczwnr?file=src/app/store/counter.query.ts

What is the motivation / use case for changing the behavior?


Happy ngxs users

Environment


Libs:
- @angular/core version: 8.0.3
- @ngxs/store version: 3.4.3


Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

For Tooling issues:
- Node version: XX  
- Platform:  

Others:

core ready to release

All 6 comments

I'm confirming this is not an issue.

image

This is not related to the NGXS itself but rather to TypeScript decorators behavior, decorators are invoked from top to bottom, so basically you're trying to access non-decorated methods yet with @Selector.

image

And yes, it works if I change an order:

image

Is there a way for library to check if the accessed method is decorated or not?
Maybe mention this behavior in a documentation?

@t-denis I understand your agitation. I'm discussing that with my NGXS teammate. Sorry for the late answer, been busy.

@t-denis I will make a PR to mention this. WIll take your code as an example if you don't mind :wink:

@t-denis I have merged a PR that should fix this issue. Please could you test with the @ngxs/store@dev package and confirm if it is fixed for you or not.

@markwhitfeld
The issue is fixed, everything works as expected. Thanks!

Was this page helpful?
0 / 5 - 0 ratings