package bonsai

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Bonsai_web_ui_fileSource

An API that allows one to read files from the client's local disk.

A value of type t can be created in two ways:

1. Using the companion library Bonsai_web_ui_file_from_web_file, which uses the Web File API to drive t. Note that the Web File API does not permit the reading of arbitrary files on the client computer's disk. Instead, one typically uses a file selector form to allow the user to specify a file to be read. See Bonsai_web_ui_form.Elements.File_picker for a convenient wrapper.

2. For tests, one can also create a t which is driven manually using the For_testing module.

Sourcetype t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval filename : t -> string
Sourceval contents : t -> string Core.Or_error.t Ui_effect.t

Get the contents of the file. For an advanced API that includes e.g. progress on loading the file, and the ability to abort in-progress reads, see read below.

Sourcemodule Progress : sig ... end
Sourcemodule Read_error : sig ... end
Sourcemodule File_read : sig ... end
Sourceval read : ?on_progress:(Progress.t -> unit Ui_effect.t) -> t -> File_read.t Ui_effect.t
Sourcemodule Read_on_change : sig ... end

Functions that take bonsai values that contain t, and kicking off reads whenever those values change.

Sourcemodule For_testing : sig ... end

This module supports a test / simulation mode where file data can be fed in by you rather than coming from an actual file on disk.

Sourcemodule Expert : sig ... end
OCaml

Innovation. Community. Security.