2 ms·
> I.e. the help-screen at the beginning is re-rendering 30 times a second, even though nothing changes. Not true. the nature of the virtual-dom is that it doe
by phamilton 12y ago
> I.e. the help-screen at the beginning is re-rendering 30 times a second, even though nothing changes.
Not true. the nature of the virtual-dom is that it doesn't rerender if nothing changes. The implementation in elm is extremely efficient. It doesn't even diff the actual DOM, it diffs the inputs to the DOM. It can do this because of the pure functional requirements of Elm.
- teh 12y agoInteresting! When I check the DOM in inspector I can see it refreshing - maybe that's a bug?
- phamilton 12y agohttp://elm-lang.org/blog/Blazing-Fast-Html.elm http://elm-lang.org/blog/Blazing-Fast-Html.elm It's possible that only applies to HTML and not to canvas. If that's the case then I would hope the technique will be applied to canvas soon.
- jwmerrill 12y agoCanvas doesn't work that way. It's immediate mode, so unless you are doing something purely additive, you reissue all draw calls on every frame. Compare to SVG, which is retained mode.
- ramy_d 12y agoIs there a benefit to use ELM, aside from its functional properties, when using the canvas then? Does using SVG with ELM offer benefits over canvas with ELM?
- skybrian 12y agoHuh? A canvas element has a buffer and it will show the same frame as last time unless you clear and redraw it. If nothing has changed then it should be easy to skip the redraw.
- dandelany 12y ago> If nothing has changed That's the hard part. The virtual-dom takes care of this for you, but in the case of canvas, you'd have to determine whether or not anything actually changed, which involves keeping around a previous state and comparing it to the new state. It's certainly doable, but nowhere near as simple as using the virtual-DOM.