Class
Scheduler
View sourceMaintains separate normal-world and cross-world registries. Each registry
maps a schedule-label constructor to an Executable. Normal-world
entries expose a Schedule; cross-world entries expose a
CrossWorldSchedule with target and source worlds. Register entries
with Scheduler#set or Scheduler#setCrossWorld, then
retrieve their schedules with Scheduler#get or
Scheduler#getCrossWorld.
Examples
import { CrossWorldSchedule, Executable, Scheduler } from '@wimaengine/schedule'
class Update {}
class Sync {}
class MainWorld {}
class SourceWorld {}
const scheduler = new Scheduler()
scheduler.set(new Executable({
label: Update,
world: MainWorld,
sourceWorld: undefined
}))
scheduler.setCrossWorld(new Executable({
label: Sync,
world: MainWorld,
sourceWorld: SourceWorld,
schedule: new CrossWorldSchedule()
}))
scheduler.get(Update)?.add((world) => console.log('update', world))
scheduler.getCrossWorld(Sync)?.add((target, source) => {
console.log('sync', target, source)
})Constructor
Methods
set(executable: Executable<Schedule, undefined>): void
View sourceRegisters an Executable in the normal-world registry.
The registry key is typeid(executable.label). Registering another
executable with the same key replaces the previous entry. Its
Schedule is returned by Scheduler#get for the same
label.
setCrossWorld(executable: Executable<CrossWorldSchedule, ConstructorFn>): void
View sourceRegisters an Executable in the cross-world registry.
The registry key is typeid(executable.label). Registering another
executable with the same key replaces the previous entry. This registry
is separate from the normal-world registry used by
Scheduler#set. Its CrossWorldSchedule is returned by
Scheduler#getCrossWorld for the same label.
get(label: ConstructorFn): Schedule
View sourceReturns the normal-world Schedule registered for a label.
The lookup uses typeid(label) in the normal-world registry and returns
the matching Executable#schedule, not the Executable.
If the label has no normal-world registration, the result is undefined.
getCrossWorld(label: ConstructorFn): CrossWorldSchedule
View sourceReturns the cross-world CrossWorldSchedule registered for a
label.
The lookup uses typeid(label) in the cross-world registry and returns
the matching Executable#schedule, not the Executable.
If the label has no cross-world registration, the result is undefined.
values(): MapIterator<Executable<Schedule, undefined>>
View sourceReturns the values iterator for the normal-world executable registry.
This is the iterator returned directly by this.executables.values().
It yields complete Executable records from the normal-world
registry in Map insertion order. A new label registered through
Scheduler#set is appended; replacing an existing label updates
its record without moving that label’s position.
crossWorldValues(): MapIterator<Executable<CrossWorldSchedule, ConstructorFn>>
View sourceReturns the values iterator for the cross-world executable registry.
This is the iterator returned directly by
this.crossWorldExecutables.values(). It yields complete
Executable records with cross-world schedules from the
cross-world registry in Map insertion order. A new label registered
through Scheduler#setCrossWorld is appended;
replacing an existing label updates its record without moving that
label’s position.
