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

fix store subscription for prop in store cases #7071

Merged
merged 7 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/proud-carrots-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik': patch
---

Fix: add subscription when doing `"prop" in store`
16 changes: 12 additions & 4 deletions packages/qwik/src/core/state/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,23 @@ export class ReadWriteProxyHandler implements ProxyHandler<TargetType> {
return true;
}

has(target: TargetType, property: string | symbol): boolean {
if (property === QOjectTargetSymbol) {
has(target: TargetType, prop: string | symbol): boolean {
if (prop === QOjectTargetSymbol) {
return true;
}
const invokeCtx = tryGetInvokeContext();
if (typeof prop === 'string' && invokeCtx) {
const subscriber = invokeCtx.$subscriber$;
if (subscriber) {
const isA = isArray(target);
this.$manager$.$addSub$(subscriber, isA ? undefined : prop);
}
}
const hasOwnProperty = Object.prototype.hasOwnProperty;
if (hasOwnProperty.call(target, property)) {
if (hasOwnProperty.call(target, prop)) {
return true;
}
if (typeof property === 'string' && hasOwnProperty.call(target, _IMMUTABLE_PREFIX + property)) {
if (typeof prop === 'string' && hasOwnProperty.call(target, _IMMUTABLE_PREFIX + prop)) {
return true;
}
return false;
Expand Down