package bonsai
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_file/Bonsai_web_ui_file/Read_on_change/index.html
Module Bonsai_web_ui_file.Read_on_change
Source
Functions that take bonsai values that contain t
, and kicking off reads whenever those values change.
The arguments here are chosen to match the results from Bonsai_web_ui_form.Elements.File_picker
. So you can do things like:
let%sub file_picker = Bonsai_web_ui_form.Elements.File_select.single () in
let%sub file_from_form =
let%arr file_picker = file_picker in
Bonsai_web_ui_form.value file_picker |> Or_error.ok
in
let%sub result = Bonsai_web_ui_file.Read_on_change.create_single_opt file_from_form in
match%sub result with
| None -> Bonsai.const None
| Some (filename, (Bonsai_web_ui_file.Read_on_change.Status.Starting | In_progress _))
->
let%arr filename = filename in
Some (filename, "file still loading")
| Some (filename, Complete (Error e)) ->
let%arr e = e
and filename = filename in
Some (filename, Error.to_string_hum e)
| Some (filename, Complete (Ok contents)) ->
let%arr filename = filename
and contents = contents in
Some (filename, contents)
NOTE: these computations are not safe for use in Tangle as internally they require a model which cannot be of_sexp
'd.
Source
val create_single_opt :
t option Bonsai.Value.t ->
(Core.Filename.t * Status.t) option Bonsai.Computation.t
Source
val create_multiple :
t Core.Filename.Map.t Bonsai.Value.t ->
Status.t Core.Filename.Map.t Bonsai.Computation.t
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>