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

Backport v3.4 Symbol.species fix for Concast and ObservableQuery. #7660

Merged
merged 7 commits into from
Feb 5, 2021

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Feb 5, 2021

I landed #7403 on the release-3.4 branch instead of main because I wasn't sure at the time if it would help fix the problem I described in #6520 (comment). Since then, multiple folks have commented that it did help, so I think it makes sense to backport this change to main (3.3.x).

While I was at it, I applied the same logic to ObservableQuery (the other Observable subclass that Apollo Client uses), and added some regression tests of the Symbol.species logic for both Concast and ObservableQuery.

An attempt to address the problems I speculated about in
#6520 (comment)

Theory: in the Hermes JS engine, Symbol.species is not defined, so
Object.defineProperty was not called, but perhaps "@@species" was getting
set somewhere else by a polyfill library, causing the zen-observable
library to fall back to "@@species" instead of using/ignoring the
nonexistent Symbol.species symbol.
Comment on lines +11 to +13
export function fixObservableSubclass<
S extends new (...args: any[]) => Observable<any>,
>(subclass: S): S {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the best way I could find to express that subclass should be a constructor function that creates a subtype of Observable.

@benjamn benjamn merged commit 7767f46 into main Feb 5, 2021
@benjamn benjamn deleted the backport-symbol-species-fix branch February 5, 2021 17:25
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants