March Docs

Arcade.Web.Runtime

Types

typeWebHooksWebHooks(model, msg, fx) = {#

A game's side of the shell. model is its model, msg its messages, fx its effects. Give a record model a one-constructor box: the JS backend names each specialization of these fns after its type arguments, and spells a record type out field by field, at every call site. hook_num the constants Arcade.Web.Paint draws with hook_boot (width, height, seed) to the first model and its effects hook_update one msg hook_perform run a batch of effects (storage, haptics, audio, ...); its first argument dispatches a msg, for an effect whose answer comes later (a network call) hook_tick the frame msg, at rAF's time hook_resize the view's new CSS size hook_down/move/up one pointer's (t, x, y) samples (Arcade.Web.Input); None sends nothing hook_cancel the pointer was lost hook_listen once at launch, after the canvas's pointer: wire any other event source (a DOM overlay's drags or fields). Its arguments read the current model and dispatch a msg hook_visible the page was shown (true) or hidden hook_scene the frame's DrawOps hook_overlay after painting: anything drawn outside the canvas, returning the msgs it produced (dispatched in order) hook_settle after the overlay's msgs, with the model they left: write model state back into the DOM (a text field) hook_marks after settle, on the same model: data-* attributes for <html>, set in order (Arcade.Web.Glue.mark)

typeWebRunWebRun(model) = {#

What the runtime keeps between events, in the one Arcade.Web.Cell: the model and the canvas with its last size.

Functions

fndispatchdispatch(h : WebHooks(model, msg, fx), x : msg) : ()#

fn current(h : WebHooks(model, msg, fx)) : model do let s = run_get(h) s.run_model end

fndispatch_somedispatch_some(h : WebHooks(model, msg, fx), x : Option(msg)) : ()#
fnfollow_sizefollow_size(h : WebHooks(model, msg, fx)) : ()#
fnframeframe(h : WebHooks(model, msg, fx), t : Float) : ()#
fnlaunchlaunch(canvas_id : String, make : () -> WebHooks(model, msg, fx)) : Result((), String)#
fnmarkmark(pair : (String, String)) : ()#
fnresizeresize(h : WebHooks(model, msg, fx), s : WebRun(model), w : Float, ht : Float, dpr : Float) : ()#
fnrun_getrun_get(_h : WebHooks(model, msg, fx)) : WebRun(model)#
fnrun_putrun_put(_h : WebHooks(model, msg, fx), s : WebRun(model)) : ()#
fnstartstart(canvas : Js.Dom.Node, ctx : Js.Canvas.Context, h : WebHooks(model, msg, fx)) : ()#