Skip to main content

Update Service

UpdateService is a global service responsible for driving the main update loop of Weo.
It coordinates frame updates, input polling, and scheduled events, acting as the timing backbone for all other services.

Update Service
Service
Singleton

Functions

UpdateService:Run()
Function

UpdateService:Run(targetFPS)

  • Runs the UpdateService, updating the UI and handling events at a specified target frame rate.

  • Uses async function which comes with LuaRT.

Parameters:

  • targetFPS
    number

The targetFPS parameter represents the desired update frequency.
It does not guarantee a fixed frame rate, since the actual timing depends on the host system’s performance and the underlying LuaRT scheduler.

UpdateService:Kill()
Method

  • Kills the UpdateService, stopping the main loop and cleaning up resources.

Signals

UpdateService.Heartbeat
Signal

  • Fires once every frame, providing the time elapsed DeltaTime since the last frame.

The Heartbeat event is non-blocking: callbacks are executed once per frame inside the update loop. While they do not block the overall loop, they also do not run concurrently — all connected callbacks are executed sequentially within the same frame tick.

Example

--- Add a FPS counter to the window
UpdateService.Heartbeat:Connect(function(DeltaTime)
window:status("FPS: " .. math.floor(1 / DeltaTime))
end)

--- Run the update loop,set target FPS to 100
UpdateService:Run(100)