In Polymer 1.0 you can drop {{localPropFoo.bar}} and bar will be observed for changes if you use this.set('localPropFoo.bar', 'new value'); to update its value.
But what to do if you want to bind template to an external object which is out of your control? E.g., this {{window.globalFoo.bar}} won't be bound to bar changes because external code doesn't depend on Polymer and doesn't call this.set.
Using Object.observe manually requires extra code and doesn't work in FireFox (dirty checks of observe.js to the rescue).
I want to know what is the idiomatic way of data binding to external objects out of your control.
Polymerdoesn't do observation out of the box, because:Object.observesupport is not ubiquitous and dirty checks are expensive.Object.observemay be expensive on itself.Supposed Solution
Catch changes yourself, call
notifyPath,this.fire('global-foo-changed', {path: 'globalFoo.bar', value:...},this.setandthis.push.They all dispatch corresponding non-bubbling (capturing)
globalFoo-changedcustom events (only when needed).Why my
global-foo-changedevents affect onlythiselement?global-foo-changedevents are capturing (non-bubbling).You may patch polymer with this behavior (I don't understand how it works):
Why No Observation Out of the Box