package fmlib_browser

  1. Overview
  2. Docs
Write web applications for the browser in elm style

Install

Dune Dependency

Authors

Maintainers

Sources

0.5.11.tar.gz
sha256=987144e79a5ab8544a9cac669284ef7610a70c3362d4f55e5d27e4f33b49a1b9

doc/fmlib_browser/Fmlib_browser/Subscription/index.html

Module Fmlib_browser.SubscriptionSource

Subscriptions to global events.

Basics

Sourcetype 'm t
Sourceval none : 'm t
Sourceval batch : 'm t list -> 'm t
Sourceval map : ('a -> 'b) -> 'a t -> 'b t

Events on the window object

Sourceval on_window : string -> 'm Decoder.t -> 'm t

on_window event_type decode

Subscribe to window events of type event_type. Examples

    on_window "resize"  decode
    on_window "keydown" decode

Incoming messages from javascript

Sourceval on_message : 'm Decoder.t -> 'm t

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

Sourceval every : int -> (Time.t -> 'm) -> 'm t

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.

Sourceval on_animation : (Time.t -> 'm) -> 'm t

on_animation f

Subscribe to the requestAnimationFrame event. The callback gets the posix time at the event.

Keyboard events

Sourceval on_keydown : (string -> 'm) -> 'm t
Sourceval on_keyup : (string -> 'm) -> 'm t

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.

Sourceval on_mouse_down : (int -> int -> 'm) -> 'm t

Subscribe to mousedown events.

Sourceval on_mouse_move : (int -> int -> 'm) -> 'm t

Subscribe to mousemove events.

Sourceval on_mouse_up : (int -> int -> 'm) -> 'm t

Subscribe to mouseup events.

Window resize

Sourceval on_resize : (int -> int -> 'm) -> 'm t

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.

Visibility change

Sourceval on_visibility_change : (string -> 'm) -> 'm t

on_visibility_change f Subscribe to the window visibility change event and report the visibility state which is either "visible" or "hidden" to the function f to generate the message for the update function.

OCaml

Innovation. Community. Security.