dustjs icon indicating copy to clipboard operation
dustjs copied to clipboard

braindump: rerenderables

Open sethkinast opened this issue 9 years ago • 1 comments

@jimmyhchan talked about this last year and I think it finally clicked for me.

dust.render returns undefined right now and uses a callback. Jimmy talked about "streaming into templates" last year and I never quite grokked it, but I think this might be it.

What about an API something like this:

let renderable = dust.render(template, context, function(err, out) {
  // some side effect, appending to or replacing DOM or whatever
});

renderable.render(anotherContext); // uses the same template and the same callback
someStream.pipe(renderable); // maybe this invokes the callback once for every data event

This would give you a renderable that you could store and reuse to update a certain portion of DOM with new data. Identifying when data changed would still be your responsibility, this is just so you don't have to manually wire it all up again.

sethkinast avatar Sep 16 '16 21:09 sethkinast

this might be related https://github.com/jimmyhchan/dustjs-stweem

jimmyhchan avatar Sep 21 '16 19:09 jimmyhchan