- From: Caridy Patiño <notifications@github.com>
- Date: Tue, 14 Nov 2017 16:28:43 +0000 (UTC)
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/708/344314714@github.com>
This seems very awkward: ```js document.defineTemplateType('self-updating-template', { createCallback: function (instance, parts, state) { onCheckPoint(() => instance.update(state)); }, processCallback: function (instance, parts, state) { for (const part of parts) part.value = state[part.expression]; }, }); ``` Considering that neither `onCheckPoint`, or `createCallback` or `processCallback` has access to the actual host, nor a way to determine when to release the control. Developers will have to do some gymnastics to add some sort of identity or protocol on the `state` object to release the control when a template instance is not longer useful. e.g.: ```js document.defineTemplateType('self-updating-template', { createCallback: function (instance, parts, state) { onCheckPoint(instance, state, (instance, state) => instance.update(state)); }, processCallback: function (instance, parts, state) { if (state === null) { // state set to null is our own protocol which means that the control should be released releaseCheckPoint(instance); return; } for (const part of parts) part.value = state[part.expression]; }, }); ``` But I understand the constrains here, and the fact that those instances might be created and even updated while still not associated to another element or shadow root. The only thing that comes to my mind to make this easier is to provide another method, equivalent to `update` on the template instance that works on the same fashion by calling the corresponding method on the template type definition so we don't have to hijack the `state` to accomplish that. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/webcomponents/issues/708#issuecomment-344314714
Received on Tuesday, 14 November 2017 16:29:34 UTC