snabbdom
snabbdom copied to clipboard
Hook signature of create
Would you be in favor of simplifying the hook signature of create
? It takes an arbitrary emptyVnode as a first argument.
The fact that the logic is reused in the core modules for the create
and update
phases should not bother users everytime they want to do something in a create
hook. I use this hook a lot and it's so annoying.
It would just be a matter of creating a wrapping function in the modules.
If you all agree, I'm happy to create a PR when I have some time.
Can you elaborate more? Creating an element while diffing two vnodes (the old one and the new one) is an important step in the process, and I don't think it has the same signature of update
just to match the api. On top of that, this will be a non-BC change...
I mean:
In the main module (snabbdom.js) the create
hook is called with an empty VNode as its first argument
As far as I know, its only purpose is to make the create
and update
functions of modules able to reuse the same function
If create
would only take the VNode with its newly created elm, then it would only be a tiny inconvenience when writing modules, something you certainly do not do everyday, and make for a better API when using the create
hook in application code, something you do often (this is basically componentWillMount of react except you have access to the elm
already).
It's a non backward compatible change, but an API simplification, easy to adjust without much thinking involved. Worth it for 0.7.0 imo.