package bonsai

  1. Overview
  2. Docs
A library for building dynamic webapps, using Js_of_ocaml

Install

Dune Dependency

Authors

Maintainers

Sources

bonsai-v0.16.0.tar.gz
sha256=1d68aab713659951eba5b85f21d6f9382e0efa8579a02c3be65d9071c6e86303

doc/bonsai.web_ui_widget/Bonsai_web_ui_widget/index.html

Module Bonsai_web_ui_widgetSource

Sourcemodule type S = sig ... end
Sourcetype ('input, 'state) t = private {
  1. view : Virtual_dom.Vdom.Node.t;
    (*

    The view of the widget

    *)
  2. modify : ('input -> 'state -> unit) -> unit Bonsai.For_open.Effect.t;
    (*

    A callback for modifying the widget. The most recent inputs and the current state of the widgets are provided.

    *)
  3. read : 'a. ('input -> 'state -> 'a) -> 'a list Bonsai.For_open.Effect.t;
    (*

    read lets you look at the most recent input and current state of any instances of the widget.

    *)
}
Sourceval component : ?vdom_for_testing:('input -> Virtual_dom.Vdom.Node.t) -> (module S with type input = 'input and type state = 'state) -> 'input Bonsai.For_open.Value.t -> ('input, 'state) t Bonsai.For_open.Computation.t

A component that makes it easy to build low-level components that make direct modifications to the DOM. Because this component returns a Vdom.Node.t and that vdom node can be placed in multiple locations in the vdom, this component actually tracks a _set of instances_ of this widget. This is why the read function produces a list of read values.

Sourcemodule Low_level : sig ... end

A mutable-state tracker is meant to be used in concert with Vdom.Node.widget or Vdom.Attr.create_hook. Because a widget and hook can exist in multiple places in the dom at the same time, this state-tracker actually tracks a collection of states, which is why read returns a list, and the callback you pass to modify can get called multiple times per invocation.

OCaml

Innovation. Community. Security.