package virtual_dom

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module State : Core.T
module Input : sig ... end

init is called the first time that this attribute is attached to a particular node. It is particularly responsible for producing a value of type State.t. The element that it is being attached to is not necessarily attached to the rest of the DOM tree.

val on_mount : [ `Do_nothing | `Schedule_animation_frame of Input.t -> State.t -> Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.t -> unit ]

on_mount specifies what happens when the element is attached to the rest of the DOM tree. When `Schedule_animation_frame is passed, the browser will call the provided function within a call to window.requestAnimationFrame() at which point the provided element will be attached to the DOM tree.

val update : old_input:Input.t -> new_input:Input.t -> State.t -> Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.t -> unit

update is called when a previous attribute of the same kind existed on the vdom node. You get access to the Input.t that the previous node was created with, as well as the State.t for that hook, which you can mutate if you like. There is no guarantee that update will be called instead of a sequence of destroy followed by init, so update should behave the same as that sequence (except it might be faster).

val destroy : Input.t -> State.t -> Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.t -> unit

destroy is called when the previous vdom has this hook, but a newer vdom tree does not. The last input and state are passed in alongside the element that it used to be attached to.

OCaml

Innovation. Community. Security.