Class
CrossWorldSchedule
View sourceCoordinates an ordered collection of executable callbacks that run with a target world and a source world.
Each callback is enabled when appended. Use
CrossWorldSchedule#add to append callbacks and
CrossWorldSchedule#run to invoke enabled callbacks in append
order. Each callback receives the target world first and the source world
second.
Examples
import { World } from '@wimaengine/ecs'
import { CrossWorldSchedule } from '@wimaengine/schedule'
const targetWorld = new World()
const sourceWorld = new World()
const schedule = new CrossWorldSchedule()
schedule.add((target, source) => {
// `target` is targetWorld; `source` is sourceWorld.
console.log('syncing the source world into the target world', source, target)
})
schedule.run(targetWorld, sourceWorld)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.
CrossWorldSchedule#run considers callbacks in append order.
Adding a callback does not execute it immediately.
run(targetWorld: World, sourceWorld: World, errorHandler?: object): void
View sourceInvokes each enabled executable callback in append order.
Each enabled callback receives targetWorld as its first argument and
sourceWorld as its second argument. Disabled entries are not called.
If an enabled callback throws, errorHandler receives the normalized
error and targetWorld; sourceWorld is not passed to the handler.
Existing Error values are passed through; thrown strings become
new Error(error), and other thrown values become new Error(String(error)).
Without a handler, the default handler rethrows the normalized error. A
custom handler that returns lets run continue with the next callback; if
the handler throws, run exits with that handler error.
