package bonsai
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=1d68aab713659951eba5b85f21d6f9382e0efa8579a02c3be65d9071c6e86303
doc/bonsai.web_ui_widget/Bonsai_web_ui_widget/index.html
Module Bonsai_web_ui_widget
Source
type ('input, 'state) t = private {
view : Virtual_dom.Vdom.Node.t;
(*The view of the widget
*)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.
*)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.
}
val 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.
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.