ghcjs / ghcjs-vdom

bindings for virtual-dom
MIT License
34 stars 16 forks source link

support for attaching event handler to virtual-dom #5

Open wavewave opened 9 years ago

wavewave commented 9 years ago

The newest version of virtual-dom supports event handling using dom-delegator library. Here is a nice writeup on the inner-working of virtual-dom and dom-delegator which is used in the mercury MVC framework : Raynos/mercury#151

I started implementing FFI binding to dom-delegator in http://github.com/wavewave/ghcjs-dom-delegator I will keep my progress posted here.

wavewave commented 9 years ago

I also created a pull request #4 making ghcjs-vdom compatible with the newest virtual-dom (2.0.1 as of now)

wavewave commented 9 years ago

now ghcjs-dom-delegator has a working example (very trivial though). dom-delegator uses a global singleton Delegator. In javascript virtual-dom, h function of virtual-hyperscript automatically registers ev-blah properties as blah event handler using the global Delegator singleton. Since ghcjs-vdom does not use virtual-hyperscript, we had better have our own similar function hook. I am going to make that extension now.

arianvp commented 9 years ago

nice :) . Would be nice if we could directly define what events we are handling within the node definition just like with virtual-hyperscript

wavewave commented 9 years ago

First success with ghcjs-vdom and ghcjs-dom-delegator! My WIP is on registerevent branch of my repo.