[FIX] reactivity: only show key in subscription if observed by callback

Previously, the getSubscriptions debugging utility returned all observed
keys for a given target, instead of only the keys observed by the
callback it received as argument. This commit fixes that issues.
This commit is contained in:
Samuel Degueldre
2023-02-09 09:54:16 +01:00
committed by Géry Debongnie
parent 33174b301b
commit fed9cc467f
3 changed files with 77 additions and 4 deletions
+9 -4
View File
@@ -162,10 +162,15 @@ export function getSubscriptions(callback: Callback) {
const targets = callbacksToTargets.get(callback) || [];
return [...targets].map((target) => {
const keysToCallbacks = targetToKeysToCallbacks.get(target);
return {
target,
keys: keysToCallbacks ? [...keysToCallbacks.keys()] : [],
};
let keys = [];
if (keysToCallbacks) {
for (const [key, cbs] of keysToCallbacks) {
if (cbs.has(callback)) {
keys.push(key);
}
}
}
return { target, keys };
});
}
// Maps reactive objects to the underlying target