[ ] 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:
If I call a helper static function from my selector function it does not continue afterwards and my observable emits undefined value.
I should be able to call a static function and the flow should continue.
@Selector()
static pandas(state: string[]) {
this.doNothing();
return state.filter(s => s.indexOf('panda') > -1);
}
static doNothing() {}
To be able to write complex selectors using helper functions
Libs:
- @angular/core version: 7.1.4
- @ngxs/store version: 3.3.3
Browser:
- [x] Chrome (desktop) version 71
- [ ] 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:
Create stackblitz example please
Here you are: https://stackblitz.com/edit/ngxs-simple-demo-9z2ckp
@splincode this is undefined inside selector, just call console.log(typeof this), also it's wrapped in try-catch thus there is no exception like cannot read property 'doNothing' of undefined
@ogix this is related to context call loss, I'll try to have a look this evening
ok, thanks!
I looked at the source code and found this.
https://github.com/ngxs/store/blob/bf13efed028ec2bbe3ca1561730237ad7f796abc/packages/store/src/utils/selector-utils.ts#L20
Shouldn't this be written in TS syntax?
const wrappedFn = (...args: any[]) => {
@ogix fixed man :rocket: