Manage frame budget with state.budget()
mainTo prevent blocking the main thread, use state.budget() to gate expensive or optional work. This is the live equivalent of requestIdleCallback's timeRemaining(). You can use it to skip work entirely if the frame is full, or to process work in chunks until the budget is exhausted.
Note: The budget is calculated based on Tempus.targetFps (default 60).
// Option 1: Run only if there is spare time
Tempus.add(({ budget }) => {
if (budget() > 0) doExpensiveWork()
})
// Option 2: Process work in chunks until budget runs out
Tempus.add((state) => {
while (state.budget() > 0) {
doChunkOfWork()
}
})