Program Module
Functions for creating and configuring Elmish game programs.
A program defines the complete architecture of a Mibo game: initialization, update logic, subscriptions, rendering, and service integration.
Example
Program.mkProgram init update
|> Program.withSubscription subscribe
|> Program.withRenderer (fun () -> Renderer2D.create view)
|> Program.withTick Tick
|> Program.withAssets
|> Program.withInput
|> RaylibGame |> _.Run()
Functions and values
| Function or value |
Description
|
Full Usage:
mkProgram init update
Parameters:
GameContext -> 'a * Cmd<'b>
-
Function that receives GameContext and returns initial (Model, Cmd)
update : 'b -> 'a -> 'a * Cmd<'b>
-
Function that receives a message and model, returns (Model, Cmd)
Returns: Program<'a, 'b>
|
Creates a new program with the given init and update functions. This is the starting point for building an Elmish game. The init function creates the initial model and startup commands, while update handles messages.
Example
val init: ctx: 'a -> struct ('b * 'c)
val ctx: 'a
val update: msg: 'a -> model: 'b -> struct ('b * 'c)
val msg: 'a
val model: 'b
val program: obj
|
|
Ensures the IAssets service is available (always true, included for API parity). The assets service is automatically created by the runtime. Use Program.withAssetsBasePath to configure a base path.
|
|
|
Full Usage:
withConfig configure program
Parameters:
GameConfig -> GameConfig
program : Program<'Model, 'Msg>
Returns: Program<'Model, 'Msg>
|
Configure game settings (resolution, title, framerate). The callback receives the current GameConfig and returns a modified copy.
Example
|
Full Usage:
withDispatchMode mode program
Parameters:
DispatchMode
program : Program<'a, 'b>
Returns: Program<'a, 'b>
|
Configures how the runtime schedules messages dispatched while processing a frame.
Use DispatchMode.Immediate for maximum responsiveness (default), or
DispatchMode.FrameBounded to guarantee that messages dispatched during
processing are deferred to the next
|
Full Usage:
withFixedStep cfg program
Parameters:
FixedStepConfig<'a>
program : Program<'b, 'a>
Returns: Program<'b, 'a>
|
Enables a framework-managed fixed timestep simulation.
When enabled, the runtime will dispatch the mapped message zero or more times per
This is complementary to Program.withTick: you can use fixed-step
messages for simulation and keep
|
|
Enables the reactive input polling service. Registers IInput in the GameContext service container. Required for using Keyboard, Mouse, Touch, and Gamepad subscription modules.
Example
|
|
Configures the game to register an IInputMapper service.
This registers IInput automatically (equivalent to Program.withInput). The mapper is ticked each frame via the runtime. If you want to stay fully "Elmish" (no service access), consider using InputMapper.subscribe instead and handle a single message.
|
|
Adds a renderer to the program. Renderers are called each frame to draw the current model state. Multiple renderers can be added (e.g., 2D UI on top of 3D scene).
Example
|
Full Usage:
withSubscription subscribe program
Parameters:
GameContext -> 'a -> Sub<'b>
program : Program<'a, 'b>
Returns: Program<'a, 'b>
|
Adds a subscription function to the program. The subscription function is called after each model update. It should return subscriptions based on the current model state. The runtime manages subscription lifecycle automatically through SubId diffing.
Example
val subscribe: ctx: 'a -> model: 'b -> 'c
val ctx: 'a
val model: 'b
|
|
Adds a per-frame tick message to the program. The tick function is called once per frame and can dispatch a message containing the GameTime for time-based updates.
Example
|
Mibo.Raylib