feat: Add signal-based binding support to ObserverMap and TemplateElement#7306
feat: Add signal-based binding support to ObserverMap and TemplateElement#7306
Conversation
863f330 to
1d10b3b
Compare
janechu
left a comment
There was a problem hiding this comment.
Let's check on the performance on this change.
change/@microsoft-fast-element-cbc19b38-8c85-4701-b1a6-8236b4644f47.json
Outdated
Show resolved
Hide resolved
f57cdf9 to
6574b51
Compare
|
I ran some AI Review and it said, can you please look into this? The most critical performance question: The old |
Good note, we are benchmarking this change next week to determine performance implications and that is why this change has not been merged. |
|
Based on performance runs this change seems fairly negligible, no real improvements or degradations. I'm hesitant to put it in based on that though I do think |
Pull Request
📖 Description
Replace the
Observable.notify-based change propagation infast-html's Observer Map and template binding system with Signal-based pub/sub from@microsoft/fast-element/binding/signal.js.The Observer Map feature previously relied on
Observable.notify(target, property)to inform bindings of deep property changes in proxied objects. This approach coupled change detection to the Observable property accessor system, which wasn't designed for the proxy-mediated, deeply-nested data patterns used in Declarative Shadow DOM templates.This PR introduces a Signal-based notification model that follows the patterns established by the
SignalBindingmodule infast-element:fh:<id>) via aWeakMapObserverMapObservercombines Signal subscriptions (for deep proxy changes) with standardObservable.bindingexpression watching (for direct property access like array items)ObserverMapBindingextends theBindingbase class and supports multi-signal subscriptions for nested repeat contextssettraps andObserverMap.defineChangedhandlers now broadcast viaSignal.sendinstead ofObservable.notifyThe public API (
TemplateElement.options,ObserverMap, template syntax) is unchanged — developers use observer maps and observables in DSD exactly as before.👩💻 Reviewer Notes
ObserverMapObserveris the central new abstraction — it's worth reviewing its dual-subscription model (Signal + Observable expression watcher) to ensure correctness across all binding contexts.notifyObservablesnow walks up the target chain recursively so nested proxies ultimately signal the owning element.📑 Test Plan
All existing Playwright fixture tests pass across Chromium, Firefox, and WebKit (336 tests). No new tests were added — the existing observer-map, deep-merge, and other fixture tests validate the behavioral equivalence of the Signal-based approach.
✅ Checklist
General
$ npm run change