package incr_dom

  1. Overview
  2. Docs

The interface for a basic, incrementally rendered application.

module Model : sig ... end
module Action : sig ... end
module State : sig ... end
val apply_action : Action.t -> Model.t -> State.t -> Model.t

apply_action performs modifications to the model as dictated by the action.

val update_visibility : Model.t -> Model.t

If you selectively render certain parts of the model based on what is visible on the screen, use update_visibility to query the state of the DOM and make the required updates in the model. Otherwise, it can be safely set to the identity function.

Changes in visibility that cause the page to reflow, thereby causing more changes in visibility, must be avoided. In order to make such bugs more visible, cascading sequences of update_visibility are not prevented.

view sets up the incremental from the model to the virtual DOM.

inject gives you the ability to create event handlers in the virtual DOM. In your event handler, call this function on the action you would like to schedule. Virtual DOM will automatically delegate that action back to the Start_app main loop.

val on_startup : schedule:(Action.t -> unit) -> Model.t -> State.t Async_kernel.Deferred.t

on_startup is called once, right after the initial DOM is set to the view that corresponds to the initial state. This is useful for doing things like starting up async processes.

val on_display : old:Model.t -> Model.t -> State.t -> unit

on_display is called every time the DOM is updated, with the model just before the update and the model just after the update. Use on_display to initiate actions.