Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In new angular v16 i'm getting ERROR TypeError: this.userQuery.select is not a function #1074

Open
samiulllah opened this issue Oct 24, 2023 · 2 comments

Comments

@samiulllah
Copy link

Is this a regression?

Yes

Description

After updating angular v11 to v16 the akita is giving error in angular
main.js:23 ERROR TypeError: this.userQuery.select is not a function at main.js:1:262487 at u.<computed> (polyfills.js:23:32704) at A.invokeTask (polyfills.js:23:9550) at Object.onInvokeTask (main.js:23:169287) at A.invokeTask (polyfills.js:23:9471) at A.runTask (polyfills.js:23:4559) at A.invokeTask (polyfills.js:23:10688) at A.invoke (polyfills.js:23:10578) at Z.s.args.<computed> (polyfills.js:23:32402)
my code chunk that raise this error is,
`ngOnInit(): void {
if (environment.phone) {
document.body.classList.add('phone');
} else {
document.body.classList.add('tablet');
}

this.screenOrientationService.lockPhone('portrait');

const userQuerySubscription = this.userQuery
.select('accessToken')
.pipe(
filter((v) => !!v),
first()
)
.subscribe(() => this.userStore.getDetails());

this.subscriptions.add(userQuerySubscription);`

I suspect that might be angular is consuming the state/store before it's avilable. Anyone else have such issue in new angular version? as it was working fine in old v11 of angular.

Please provide a link to a minimal reproduction of the bug

https://stackoverflow.com/questions/77354907/angular-v16-and-akita-is-giving-error-typeerror-this-userquery-select-is-not-a

Please provide the exception or error you saw

main.js:23 ERROR TypeError: this.userQuery.select is not a function
    at main.js:1:262487
    at u.<computed> (polyfills.js:23:32704)
    at A.invokeTask (polyfills.js:23:9550)
    at Object.onInvokeTask (main.js:23:169287)
    at A.invokeTask (polyfills.js:23:9471)
    at A.runTask (polyfills.js:23:4559)
    at A.invokeTask (polyfills.js:23:10688)
    at A.invoke (polyfills.js:23:10578)
    at Z.s.args.<computed> (polyfills.js:23:32402)

Please provide the environment you discovered this bug in

development

Anything else?

I'm suspecting that angular v16 consume stores/queries before they are avilable resulting in undefined.

Do you want to create a pull request?

No

@samiulllah
Copy link
Author

samiulllah commented Oct 25, 2023

@hakimio
Copy link

hakimio commented Mar 7, 2024

Another solution could be to use getter:

get selectAll$() {
    return this.selectAll();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants