Obligatory obligation

Is there a way to set up bindings imperatively. Usage example:

var el2 = new MyElement(); el2.myProp = this.$.anotherElement.anotherProp 

This will not set the binding, just assign a value or object. I would like to find a way to do something like:

 el2.myProp.bindTo(this.$.anotherElement.anotherProp) 

Possible?

+5
source share
1 answer

Polymer 1.0 does not currently support this - as explained by @kevinpschaaf on Github https://github.com/Polymer/polymer/issues/1778 .

(comment from @kevinpschaaf)

No, we do not currently support this, outside of dom-bind, which is only a template implementation that will be late with child instances. You can document.createElement ('template', 'dom-bind'), then you can dynamically add children with anchored annotations to your content, and anchors will only be evaluated after the dom-bind is attached to the document. See here the tests that show this usage: https://github.com/Polymer/polymer/blob/master/test/unit/dom-bind.html#L95

Please note that dom-bind currently does not allow you to snap to the outer area, so it has limited use in templates of custom elements (the main use case for snapping between elements in the main document), and this is not likely to change in the short term.

We achieve great performance optimization by baking the connection of compounds in the prototype during registration for (and not during the instance), and we have not created enough equipment to easily add / remove bindings at runtime.

+6
source

Source: https://habr.com/ru/post/989942/


All Articles