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_form/Bonsai_web_ui_form/Dynamic/index.html

Module Bonsai_web_ui_form.DynamicSource

Unlike the rest of the API which operates on values of type Form.t value values, they operate on Form.t Value.t, and typically return Computation.t.

Unlike the rest of the API which operates on values of type Form.t value values, they operate on Form.t Value.t, and typically return Computation.t.

Sourceval with_default : 'a Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Computation.t
Sourceval with_default_from_effect : 'a Bonsai_web.Effect.t Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Computation.t
Sourceval with_default_always : 'a Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Computation.t
Sourceval error_hint : 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Computation.t

Adds a clickable error hint for this form

Sourceval collapsible_group : ?starts_open:bool -> string Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Computation.t

Adds a group that is clickable. Visibility for sub-forms is initially determined by starts_open but is toggled by clicking on the label.

Sourceval on_change : ?on_error:(Core.Error.t -> unit Ui_effect.t) Bonsai_web.Value.t -> (module Bonsai_web.Bonsai.Model with type t = 'a) -> f:('a -> unit Ui_effect.t) Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Value.t -> unit Bonsai_web.Computation.t

Adds a on_change handler to a Form.t.

The function f is called when 1. the (successfully validated) value of the form changes. 2. the form transitions from producing an Error to producing a value. 3. the form initializes with a value

on_error is called when 1. the error message changes 2. the form transitions from producing a value to an error 3. the form initializes with an error

Sourceval sync_with : (module Bonsai_web.Bonsai.Model with type t = 'a) -> store_value:'a option Bonsai_web.Value.t -> store_set:('a -> unit Bonsai_web.Effect.t) Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Value.t -> unit Bonsai_web.Computation.t

Synchronizes a form with some external storage. The value from the store is used to initially populate the form, and if the form changes, then the store is updated to match. If the contents of the store changes, the form is also updated to match. If both the form and the store update at the same time, the form wins, and the store is overridden.

Sourceval validate_via_effect : (module Bonsai_web.Bonsai.Model with type t = 'a) -> ?one_at_a_time:bool -> ?debounce_ui:Core.Time_ns.Span.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Value.t -> f:('a -> unit Core.Or_error.t Bonsai_web.Effect.t) Bonsai_web.Value.t -> 'a Bonsai_web_ui_form__.Form.t Bonsai_web.Computation.t

Unlike validate which requires the validation function to be available locally (and synchronous), validate_via_effect runs an effectful computation. The asynchrony makes this function interesting:

When a value is in the midst of validated, the resultant form is resolved to an Error.

one_at_a_time (defaults to false) when set to true, will use Bonsai.Effect_throttling.poll to make sure that only one instance of the effect

debounce_ui can be set to a timespan. When set, the validation status won't update until the input form value has been stable for the given span of time

Sourcemodule Record_builder : sig ... end
OCaml

Innovation. Community. Security.