[FIX] owl-core: signal collections track per-key, not per-signal#1903
Open
ged-odoo wants to merge 3 commits into
Open
[FIX] owl-core: signal collections track per-key, not per-signal#1903ged-odoo wants to merge 3 commits into
ged-odoo wants to merge 3 commits into
Conversation
Reading `.has(k)` / `.get(k)` on a `signal.Set` / `signal.Map` / `signal.WeakMap` was subscribing to the signal atom instead of a per-key atom, so mutating *any* key (e.g. `signal.Set(...).add(2)`) re-ran every observer of the collection — even one that only read `has(1)`. The collection helpers in proxy.ts now pass `null` to onReadTargetKey / onWriteTargetKey, restoring per-key tracking. Shallow inner-value wrapping still respects the signal atom via possiblyReactive, so the existing "X item is not reactive" tests keep passing. Closes #1902
2e2928b to
6861c35
Compare
Spell out what signal.Array / signal.Object / signal.Set / signal.Map actually do: the proxy wrapping, the .set(newValue) replacement API, the shallow caveat, and — newly — the tracking granularity asymmetry. signal.Array and signal.Object invalidate the whole signal on any write; signal.Set and signal.Map track per-key, matching the behavior of proxy(). The latter was a documented-elsewhere assumption that confused users (cf. #1902); it now has a concrete example.
…ment signal.Array / signal.Object / signal.Set / signal.Map now default to an empty collection when no initial value is passed, so the common case of "reactive bag, fill it later" reads more naturally: const items = signal.Array<Todo>(); const cache = signal.Map<string, User>(); Suggested by seb-odoo in #1902 (Note 2).
6861c35 to
8a5076c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reading
.has(k)/.get(k)on asignal.Set/signal.Map/signal.WeakMapwas subscribing to the signal atom instead of a per-key atom, so mutating any key (e.g.signal.Set(...).add(2)) re-ran every observer of the collection — even one that only readhas(1).The collection helpers in proxy.ts now pass
nullto onReadTargetKey / onWriteTargetKey, restoring per-key tracking. Shallow inner-value wrapping still respects the signal atom via possiblyReactive, so the existing "X item is not reactive" tests keep passing.Closes #1902