Hi all,

If you don't care about design minutiae of databinding, you can stop
reading now.

I've been thinking about the semantics of ref and assigning the
bindingDelegate and there are a few problems with our current behavior

-Assigning a different binding delegate once a template has begun producing
instances affects only future (not present) instances, resulting,
potentially, in instances coexisting with different binding delegates.

-Ref (as in <template ref>) is resolved every time an instance is produced.
This is potentially wasteful

-There's no way to "clear" a template (remove all instances and stop it
from operating)

Also, https://github.com/Polymer/TemplateBinding/issues/151 shows that
binding to ref dynamically is potentially useful.

As such, I propose some semantic/API changes as well as a design invariant:

Invariant:

-At any given time a template should have instances which are more or less
"of the same mold" (e.g. produced from the same template.content and
bindingDelegate).

Semantic/API changes:

-template should have a clear() API, which removes all instances,
essentially resetting the template's internal state (clearing the model,
bindingDelegate, etc...).

-ref should be resolved once, the first time a template produces an
instance.

-assigning to ref causes the template to remove its instances and reproduce
new ones using the newly referenced content (by extension binding to ref
this to be declarative).

-assigning to bindingDelegate once the template model is assigned throws an
Error. I realize this isn't very DOM-y, but the alternative which ensures
the invariant is to act like ref, removing all instances and starting over.
In the case of bindingDelegate, it's less clear there are use cases which
drive this and simple ordering mistakes (assigning the bindingDelegate
after the model) potentially create a very expensive no-op which is easy
not to notice.

I'm going start working on patches for the above, but I'm interested in
opinions.

Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/CABMdHiQOusMOW1FbV9fCiC1PkY3%2BDR53gFMgccLZjuNONURsVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to