Library
Module
Module type
Parameter
Class
Class type
A "Virtual application" (or "Elm-like" application) is described by two types:
and by the following values:
Commands represents (typically) asynchronous operations, such as querying a server, or waiting for some timer.
Messages can be generated either by a VDOM tree (to encapsulate DOM events) or by commands (to notify their outcome).
module Cmd : sig ... end
module Decoder : sig ... end
module Custom : sig ... end
type +'msg event_handler =
| Decoder : {
event_type : string;
decoder : 'a msg_options Decoder.t;
map : 'a option -> 'msg option;
} -> 'msg event_handler
| CustomEvent of Custom.event -> 'msg option
type 'msg attribute =
| Property of string * prop_val
| Style of string * string
| Handler of 'msg event_handler
| Attribute of string * string
val on_with_options : string -> 'msg msg_options Decoder.t -> 'msg attribute
val on_js_with_options :
string ->
(js_object -> 'msg msg_options) ->
'msg attribute
val onmousedown :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attribute
val onmousedown_cancel :
?stop_propagation:unit ->
(mouse_event -> 'msg option) ->
'msg attribute
val onmouseup :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attribute
val onclick :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attribute
val onclick_cancel :
?stop_propagation:unit ->
(mouse_event -> 'msg option) ->
'msg attribute
val ondblclick :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attribute
val onfocus :
?prevent_default:unit ->
?stop_propagation:unit ->
'msg ->
'msg attribute
val onblur :
?prevent_default:unit ->
?stop_propagation:unit ->
'msg ->
'msg attribute
val oninput :
?prevent_default:unit ->
?stop_propagation:unit ->
(string -> 'msg) ->
'msg attribute
Pass the value
property of the event target.
val onchange_checked :
?prevent_default:unit ->
?stop_propagation:unit ->
(bool -> 'msg) ->
'msg attribute
Pass the checked
property of the event targer.
val onchange :
?prevent_default:unit ->
?stop_propagation:unit ->
(string -> 'msg) ->
'msg attribute
Pass the value
property of the event target.
val onchange_index :
?prevent_default:unit ->
?stop_propagation:unit ->
(int -> 'msg) ->
'msg attribute
Pass the selected_index
property of the event target.
val onmousemove :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attribute
val onmouseenter :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attribute
val onmouseleave :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attribute
val onmouseover :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attribute
val onpaste :
?prevent_default:unit ->
?stop_propagation:unit ->
(paste_event -> 'msg option) ->
'msg attribute
val oncustomevent : (Custom.event -> 'msg option) -> 'msg attribute
Generic DOM properties correspond to actual properties on DOM objects. The name of these properties is usually the same as the corresponding HTML attribute, but not always (e.g. "class" attribute, but "className" property).
val str_prop : string -> string -> 'msg attribute
val int_prop : string -> int -> 'msg attribute
val bool_prop : string -> bool -> 'msg attribute
val float_prop : string -> float -> 'msg attribute
val style : string -> string -> 'msg attribute
A sub-field of the "style" DOM property.
val attr : string -> string -> 'msg attribute
val int_attr : string -> int -> 'msg attribute
val float_attr : string -> float -> 'msg attribute
val class_ : string -> 'msg attribute
val type_ : string -> 'msg attribute
val type_button : 'msg attribute
val value : string -> 'msg attribute
val disabled : bool -> 'msg attribute
Pseudo-attributes are interpreted in a special way by the infrastructure.
val scroll_to_show : align_top:bool -> 'msg attribute
When this pseudo-attribute is first applied to an element, its parent is automatically scrolled (vertically) to show the element.
val autofocus : 'msg attribute
When this pseudo-attribute is first applied to an element, the element gets focused.
val autofocus_if_visible : 'msg attribute
When this pseudo-attribute is first applied to an element, the element gets focused if the element is visible in the viewport.
val autofocus_counter : int -> 'msg attribute
When this pseudo-attribute is first applied to an element, or applied with a different counter as the previous time, the element gets focused.
val select : 'msg attribute
When this pseudo-attribute is first applied to an input or textarea element, select the content.
val autosubmit : 'msg attribute
When this pseudo_attribute is first applied to a form element, it will be submitted automatically.
type ('msg, 'res) elt_gen = ?key:string -> ?a:'msg attribute list -> 'res
A generic element in the SVG namespace.
val text : ?key:string -> string -> 'msg vdom
A text node.
A fragment node (not appearing in the dom).
Map attributes of a vdom element
Wrap all messages generated by a VDOM tree with the provided function.
Apply the function to generate a VDOM tree only if the function or its argument have changed (physically) from the previous synchronization.
Note that physical equality is used both for the function and its argument. In particular, this is unlikely to behave as expected if the function is defined inline (as an abstraction) or obtained by a (partial) function application. Instead, the functional argument should be a simple reference to a globally defined function.
TODO: n-ary versions
.
val custom :
?key:string ->
?a:'msg attribute list ->
?propagate_events:unit ->
Custom.t ->
'msg vdom
A custom kind of node. Usually not used directly.
val simple_app :
init:'model ->
update:('model -> 'msg -> 'model) ->
view:('model -> 'msg vdom) ->
unit ->
('model, 'msg) app
A simple app does not trigger commands.
val to_html : 'msg vdom -> string
Convert to HTML