Class
Schedule
View sourceRepresents an ordered collection of executable callbacks.
Each callback is enabled when appended. Use Schedule#add to
append callbacks and Schedule#run to invoke enabled callbacks
in append order with a world.
Examples
import { World } from '@wimaengine/ecs'
import { Schedule } from '@wimaengine/schedule'
const world = new World()
const schedule = new Schedule()
schedule.add((world) => {
console.log('running a callback', world)
})
schedule.run(world)Constructor
Methods
add(system: object): number
View sourceAppends an executable callback to the schedule and enables it.
The returned number is the callback’s zero-based position.
Schedule#run considers callbacks in append order, and adding
a callback does not execute it immediately.
run(world: World, errorHandler?: object): void
View sourceInvokes each enabled executable callback in append order.
The world argument is passed as the only argument to every enabled
callback and as the second argument to errorHandler. Disabled entries
are skipped without being called.
If an enabled callback throws, errorHandler receives the normalized
error and the same world. Existing Error values are passed through;
thrown strings become new Error(error), and other thrown values become
new Error(String(error)). When no handler is provided, the default
handler rethrows the normalized error. A custom handler that returns lets
execution continue with the next callback; if it throws, run exits with
that handler error.
