HeinrichApfelmus / threepenny-gui

GUI framework that uses the web browser as a display.
https://heinrichapfelmus.github.io/threepenny-gui/
Other
437 stars 77 forks source link

Add support for synthetic events (CustomEvent) #196

Closed meteficha closed 6 years ago

meteficha commented 6 years ago

Synthetic events use CustomEvent(), which contains a customizable detail attribute. This PR allows that attribute to be passed to the Haskell side, allowing one to, say, use:

on (domEvent "myEvent") elm $ ...

on the Haskell side, and:

var ev = new CustomEvent("myEvent", { detail: ... });
elm.dispatchEvent(ev);

on the JavaScript side.

Cf. https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent

ndmitchell commented 6 years ago

This seems very useful, anything blocking its review?

HeinrichApfelmus commented 6 years ago

This seems very useful, anything blocking its review?

A lack of leisure time? 😄🖇

I wasn't quite sure how this affects marshalling event data. Apparently, it doesn't, event data is still JSON.

Merged, thanks!

meteficha commented 6 years ago

Wicked, thank you!