package bonsai

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

Install

Dune Dependency

Authors

Maintainers

Sources

bonsai-v0.15.0.tar.gz
sha256=24c4c3149280abd639034ce3acf60e475a772202099e965be8bd8902524573ef

doc/bonsai.web_ui_file/Bonsai_web_ui_file/Read_on_change/index.html

Module Bonsai_web_ui_file.Read_on_change

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_picker.create [%here] ()
  in
  let%sub current_file =
    Bonsai_web_ui_file.Read_on_change file_picker
  in
  match%sub current_file with
  | Starting | In_progress _ -> Bonsai.const "file still loading"
  | Complete (Error e) -> Bonsai.read (e >>| Error.to_string_hum)
  | Complete (Ok (_filename, contents)) -> Bonsai.read contents

NOTE: these computations are not safe for use in Tangle as internally they require a model which cannot be of_sexp'd.

module Status : sig ... end
val create_single_opt : t option Bonsai.Value.t -> (Core.Filename.t * Status.t) option Bonsai.Computation.t
OCaml

Innovation. Community. Security.