Open Emasoft opened 9 years ago
Implemented factory for stateless "components"
final vHello = vComponentFactory(Hello);
class Hello extends Component {
@property String name;
build() => vRoot()('Hello $name');
}
now can be implemented like this:
final vHello = vStaticTreeFactory(({name}) => vdom.div()('Hello $name'));
I like build
instead of React's render
as it better conveys what actually happens.
Nice @ factory for simple components without special behaviour.
@ lifecycle methods:
For being attached/detached
from the virtual DOM: when would I use them?
I also think that it would be a good idea to match the naming of web components and use attached/detached
for the actual DOM.
Sometimes component should stop respond to events like click
when it is removed from the virtual dom, because when the parent component implements some kind of transitions, visual representation of the removed element can stay a little longer in the document, and user can activate event handlers for this component when it is actually removed and it can lead to some nasty bugs.
I am not sure that there should be any default behavior for such case, maybe developer doesn't want to block events even when it is removed from the virtual dom, but there should be lifecycle method for this case.
There is probably no need for "attached to virtual dom" method, I don't see any use case for this.
There are other ways how developers can prevent this kind of bugs, but I want to give them a choice, I think that it will be useful.
Thanks for the clarification, I still have to wrap my head around animation and stuff like that in combination with virtual dom concepts.
I tried it and I liked it (even if it is, unfortunately, non isomorphic), but I think that there should be a simpler syntax to define components. 59 lines to define a checkbox component? Really? This isn't gonna work. Simplification is the only way to make this working.