Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows hooks to also receive a reference of the vpatch instance. #212

Closed
wants to merge 1 commit into from
Closed

Allows hooks to also receive a reference of the vpatch instance. #212

wants to merge 1 commit into from

Conversation

jails
Copy link
Contributor

@jails jails commented Apr 2, 2015

This PR allows hooks to also receive a reference of the vpatch instance.
When a node is created, there was no easy way to retreive all the properties used for creating the node.
This would be particularly useful when the vdom is automatically generated from some html template. This way, the hook system can also be used in a wider range.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 97.5% when pulling f4e37ce on jails:hook-receive-vpatch into 1186cdc on Matt-Esch:master.

@Zolmeister
Copy link
Contributor

I am worried that exposing the vpatch directly opens up the API surface too much.
Might there be an alternative solution in user-land? (or at least define a new data structure for containing the v-node construction)

@jails
Copy link
Contributor Author

jails commented Apr 2, 2015

Maybe hooks was not the concept I was looking for. The documentation stated that hooks are "mechanisms for executing functions after a new node has been created". But looks likes they are more "mechanisms to control how a node attribute should behave on a change".

Did I miss something or there's not really a mechanism which allow to execute a function after a new node has been created ?

@jails
Copy link
Contributor Author

jails commented Apr 3, 2015

Closed in flavor of #213

@jails jails closed this Apr 3, 2015
@jails jails deleted the hook-receive-vpatch branch April 3, 2015 02:44
@dylanmcdiarmid
Copy link
Contributor

@jails: Hooks aren't specifically for controlling node attributes. They are for doing things immediately after a virtual element has been turned into a real element (presumably things you couldn't do while the element was still virtual).

For example, say you want an element to focus on the next redraw. There is no property you can set on the HTMLElement to make that happen, because you have to call the HTMLElement.focus() method. So you create a hook to do it instead (although waiting for a new animation frame / tick, because hooks are called while the rendering is still happening).

Although this might not be the problem for it (it looks like you've already moved on), I personally don't see any issue with the vpatch being passed to hooks, but then I don't mind virtual-dom giving me enough rope to hang myself if it lets me tie a few new knots :)

@jails
Copy link
Contributor Author

jails commented Apr 3, 2015

Oh ok thanks the head up @Littleloops! Yeah I finally moved on because if Hooks gave some control over created node, I realized that beeing able to control the rendering step (i.e overriding "vdom/create-element.js" #213) was definilty the logic I needed to be able to customize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants