package fmlib_browser
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=22d5648fe40ab6c6106ee4c7092db6f3547b721c299092dd12f092a307c8ac59
doc/fmlib_browser/Fmlib_browser/Subscription/index.html
Module Fmlib_browser.SubscriptionSource
Subscriptions to global events.
Basics
Events on the window object
on_window event_type decode
Subscribe to window events of type event_type. Examples
on_window "resize" decode
on_window "keydown" decodeIncoming messages from javascript
on_message decode
Subscribe to incoming messages from the javascript world. If there is an incoming message (a javascript object) then decode the object with the help of the function decode and send the decoded value as a message to the update function of the application.
Timer events
every millis f Subscribe to an event which is fired every millis milliseconds. Use f to map the posix time into a message for the update function.
on_animation f
Subscribe to the requestAnimationFrame event. The callback gets the posix time at the event.
Keyboard events
Mouse events
The following mouse event subscriptions just decode the clientX and clientY value of the mouse event. But a mouse event has much more information. You can get a customized subscription which decodes more mouse event data by just writing a decoder decode which decodes all values from a mouse event which are of interest and subscribe to the mouse event e.g. by on_window "mouseup" decode.
Window resize
on_resize f Subscribe to the window resize event and report the innerWidth and innerHeight properties to the function f to generate the message for the update function.