Module Useri.App

module App: sig .. end
Application


Environment


val env : string -> default:'a -> (string -> 'a) -> 'a
env var ~default parse lookups var in the environment, parses it with parse and returns the result. If parse raises or if var is not in the environment default is returned.

Data lookup depends on the backend:


val prefs_path : org:string -> app:string -> (string, [ `Msg of string ]) Result.result
TODO this should used the app name automatically. Unique to user and app.

User requested quit


val quit : unit React.event
quit occurs whenever the user requested to quit. The meaning depends on the backend: .

Init, run and release


val init : ?name:string ->
?surface:Useri.Surface.t -> unit -> (unit, [ `Msg of string ]) Result.result
init name surface initialises an application named name (default derived from the executable name) with surface surface (defaults to a default Useri.Surface.create.)
val run_step : unit -> Useri.Time.span
run_step () gather as much user input as possible and returns the maximal timespan after which Useri.App.run_step should be called again.
val run : ?until:'a React.event -> unit -> unit
run until depends on the backend scheme:
val release : ?sinks:bool -> unit -> unit
release sinks () does the following:
  1. Makes the Useri.App.stop event occur.
  2. If sinks is true (default), calls Useri.App.release_sinks.
  3. Reclaims other resources

After a Useri.App.release it should be possible to Useri.App.init again.

val start : unit React.event
start occurs the first time either Useri.App.run_step or Useri.App.run is called.
val stop : unit React.event
stop occurs when Useri.App.release starts.

Event and signal sinks


val sink_event : 'a React.event -> unit
sink_event e keeps a reference on e until the app exits.
val sink_signal : 'a React.signal -> unit
sink_signal s keeps a reference on s until the app exits.
val release_sinks : unit -> unit
Stops and release sink references. In the `Jsoo backend stops are strong.

Launch context


type launch_context = [ `Browser | `Gui | `Terminal ] 
val launch_context : launch_context
launch_context is the mechanism that started the program.
val pp_launch_context : Format.formatter -> launch_context -> unit
pp_launch_context ppf c prints an unspecified representation of c on ppf.

Platform and backend


val platform : string
platform is the name of the platform you are running on.

Warning. Do not expect different backend to report the same platform with the same string.

type backend = [ `Jsoo | `Other of string | `Tsdl ] 
The type for Useri's backends.
val backend : backend
backend is Useri's current backend.
val pp_backend : Format.formatter -> backend -> unit
pp_backend ppf b prints an unspecified representation of c on ppf.
val set_backend_logger : ([ `Error | `Warning ] -> string -> unit) -> unit
set_backend_logger log sets log to be called by backends whenever non-fatal internal warnings and errors are generated. The default function outputs and flushes to stderr.
type backend_scheme = [ `Async | `Sync ] 
The type for backend scheme.
val backend_scheme : [ `Async | `Sync ]
backend_scheme is the Useri's current backend's scheme.
val pp_backend_scheme : Format.formatter -> backend_scheme -> unit
pp_backend_scheme ppf bs prints and unspecified representation of bs on ppf.

CPU count


type cpu_count = [ `Known of int | `Unknown ] 
The type for CPU counts.
val cpu_count : cpu_count
cpu_count is the number of CPU available.
val pp_cpu_count : Format.formatter -> cpu_count -> unit
pp_cpu_count ppf c prints an unspecified representation of c on ppf.