package ocaml-canvas

  1. Overview
  2. Docs

Initialization and event loop control

val init : unit -> unit

init () initializes the backend


  • Failure if initialization fails
val run : (unit -> 'dummy1) -> 'dummy2

run k executes the backend event loop, calling update functions as needed, and calling the continuation function k when the event loop terminates. Note that the call to run MUST be the last instruction in your program (to avoid different behaviors between the native and javascript backends). If you need to perform additional stuff when the program terminates, you MUST use the k function: it is meant for that. Note that calling run from an update function will just be ignored (though this should not be done). However, run may be called from the k function, if needed.


val stop : unit -> unit

stop () requests termination of the currently running event loop, if any. It should be called from an update function. Actual termination of the event loop will occur at the end of the current iteration of the event loop, so after calling stop an update function should proceed normally until it returns.


val getCanvas : int -> Canvas.t

getCanvas i returns the canvas that has id i, if it exists


val getCurrentTimestamp : unit -> Event.timestamp

getCurrentTimestamp () returns the current timestamp in microseconds, from an arbitrary starting point



Innovation. Community. Security.