package bonsai

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

Install

Dune Dependency

Authors

Maintainers

Sources

v0.15.1.tar.gz
sha256=0c4a714146073f421f1a6179561f836b45d8dc012c743207d3481ea63bef74bf

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

Module Bonsai_web_ui_file.Read_on_changeSource

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.

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

Innovation. Community. Security.