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

wrap off(firebaseQuery, 'value', valueUnsubscribe) in setTimeout-0 #287

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tobias74
Copy link

Description

In some cases (especially when frequently subscribing and unsubscribing geo queries) there was an error:

Uncaught ReferenceError: Cannot access 'valueUnsubscribe' before initialization
at GeoQuery.ts:485:37

It seems that in those cases the callback provided to onValue was called synchronously before returning valueUnsubscribe from the function call. Therefore valueUnsubscribe was not yet fully defined (Temporal Dead Zone ?)

@tobias74
Copy link
Author

tobias74 commented Oct 26, 2024

I have just looked into the docs for onValue: it returns an unsubscribe function. So my question is: Does this implementation:

off(firebaseQuery, 'value', valueUnsubscribe);

really unsubscribe correctly? Shouldn't it just be:

valueUnsubscribe();

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

Successfully merging this pull request may close these issues.

1 participant