package vdom

  1. Overview
  2. Docs
type t

A controller for a custom element.

type event =
  1. | Custom of Vdom.Custom.event
  2. | Encoded of {
    1. event_type : string;
    2. encoder : Encoder.t;
    }
val blur_event : event
val input_event : string -> event
val checked_event : bool -> event
val change_event : string -> event
val change_index_event : int -> event
val custom_event : Vdom.Custom.event -> event
val make : ?dispose:(unit -> unit) -> sync:(Vdom.Custom.t -> bool) -> Js_browser.Element.t -> t

Create a custom controller out of DOM element.

The sync function is in charge of updating the internal state of the custom element when the VDOM changes. It must return true if the update was successful, or false if the element needs to be destroyed and recreated.

type ctx

Context for custom element handlers.

val parent : ctx -> Js_browser.Element.t
val send_event : ctx -> event -> unit

Can only be called after the handler returns (typically in a DOM event callback).

val after_redraw : ctx -> (unit -> unit) -> unit

Record an action to be executed after the next redraw.

type handler = ctx -> Vdom.Custom.t -> t option

A custom element handler recognizes some kinds of custom elements described in the VDOM and instantiante a concrete controller for them.

OCaml

Innovation. Community. Security.