News for hackers. Stuff that matters.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by gima on Saturday July 16, 2016 @05:41PM (#12107986)
I'm kinda out of the loop with Javascript nowdays, but how would one react to changing data on some input element and receive it in Javascript, integrating elegantly with this library?
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by wrong_variable on Saturday July 16, 2016 @05:56PM (#12108033)
easy, using vanilla.js !

you attach event-handlers to each virtual-dom the same way you would do with a normal-dom.

and those event-handlers can react to change the way you want.

If you mean how to do auto-data binding

oldDom = patch (document.body,newDom)

newDom = h ('div','hello world')

patch (oldDom,newDom)

patch is the function that does the dom diffing.

The amazing thing is most web components do not need auto-diffing.

Sometimes you want fine grained control where you write your own update functions - making imperative changes to the dom based on your needs.

And for other web components where you want more auto-updates you can patch accordingly.

The thing that is amazing is that you can dial it up and down based on your individual needs.

A good example is table components with a lot of data.

You really do not want to incrementally update the table.

So for the divs with the data you patch

but other components that have a lot of interactivity you can simply not patch and do updates by hand.

Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by tobr on Saturday July 16, 2016 @06:06PM (#12108059)
There's an event module built into snabbdom, so you can add a handler for `input` events, change whatever state you want, then create a new vnode and patch the dom. The architecture is very much up to you, snabbdom just updates the dom.