Refactor dependency on dart:html
Closed this issue · 5 comments
We need to remove the direct dependency on dart:html for most of the classes in butterfly, in order to support running the application outside of the browser (server, tests, workers).
I'd propose creating an abstract Renderer class which could have platform dependent implementations: DomRenderer, TestRenderer, and so on.
For example, currently on the StatelessWidget render we have the following method:
RenderNode instantiate(Tree t) => new RenderStatelessWidget(t, this);
I'd propose a design something like this
R instantiate<R>(Renderer<R> renderer) => renderer.renderStatelessWidget(this);
Some open questions:
- Should the instantiate method even return a value, or can it all be done internally in the
Renderer
? - Can the renderer handle
Tree
construction without the widget's knowledge?
Another possibility is an abstract diff tree, similar to what did in the barista prototype. The idea is that the environment gives the node tree an interface to sync to, and that object can have multiple implementations, similar your Renderer
approach.
The difference between a Renderer
and diff tree is that this approach is a little more functional-style where the diff tree itself is a value that is passed around. Then we can share implementations of Node
and RenderNode
classes.
Let's sync about which way to go. We should also get @matanlurey's view on this.
design and start this almost over from the beginning
It's treason then.
@matanlurey could you please describe the issues with a renderer? Perhaps there are ways to fix them without going back to the whiteboard.