Closed kuraga closed 8 years ago
As it is now. Not in current state. We have a few hooks for events etc that will be exposed later on. On Jan 5, 2016 12:37 AM, "Alexander Kurakin" notifications@github.com wrote:
https://github.com/paldepind/snabbdom#hooks
Is this approach interesting for Inferno?
— Reply to this email directly or view it on GitHub https://github.com/trueadm/inferno/issues/60.
There are some future plans to enable hooks with refs. For example:
const ref = Inferno.createRef();
ref.on("created", ...);
ref.on("attached", ...);
ref.on("detached", ...);
ref.on("updated", ...);
ref.on("destroyed", ...);
It's arguably not needed at all though, unless people are using Inferno to build bigger frameworks. You can get the above easily via the component lifecycle API. I do see big value in using it when using a stateless component model – so it will go on the roadmap!
Yes, it's cool as helps Snabbdom to produce its plugin system. I just think plugin system is very valuable so it's important to remember possible approaches and don't miss it!
Change of plan, I'll go down the route of providing direct element support for hooks (as like Snabbdom). These will be matched as below:
export const hookTypes = {
// DOM nodes
onCreated: true,
onAttached: true,
onWillDetach: true,
onWillUpdate: true,
onDidUpdate: true,
// Components
onComponentWillMount: true,
onComponentDidMount: true,
onComponentWillUnmount: true,
onComponentShouldUpdate: true,
onComponentWillUpdate: true,
onComponentDidUpdate: true
};
Good man! I'm sure this kind of low level hook will prove a godsend down the road as optimization vectors and use cases evolve.
Okay, hooks have been implemented in the latest push of dev
if you guys want to try it out and test it. You use it like:
<div onCreated={ ... } />
https://github.com/paldepind/snabbdom#hooks
Is this approach interesting for Inferno?