Executable

View source

Represents the execution metadata for a labeled schedule.

An executable pairs a schedule label with its schedule, target world, timing and repeat options, and optional source-world, group, and error-handling settings. Normal schedules use a Schedule. Schedules that pass callbacks between two worlds use a CrossWorldSchedule.

Examples

import { CrossWorldSchedule, Executable } from '@wimaengine/schedule'

class Update {}
class Sync {}
class MainWorld {}
class SourceWorld {}

const normal = new Executable({
  label: Update,
  world: MainWorld,
  sourceWorld: undefined
})
const crossWorld = new Executable({
  label: Sync,
  world: MainWorld,
  sourceWorld: SourceWorld,
  schedule: new CrossWorldSchedule()
})

Constructor


constructor<ScheduleType, SourceWorldType extends ConstructorFn>(config: ExecutableConfig<ScheduleType, SourceWorldType>)

View source

Creates an executable binding from the supplied configuration.

Normal configurations use sourceWorld: undefined; cross-world configurations provide a source-world label and a CrossWorldSchedule. A nullish schedule defaults to a new Schedule. Nullish repeat and delay values default to true and 0.

Type Parameters

ScheduleType

SourceWorldType extends ConstructorFn

Parameters

NameDescriptionDefault
config——

Properties


readonlyschedule: ScheduleType

View source

Schedule run for this label.

A normal executable uses a Schedule. A cross-world executable uses a CrossWorldSchedule. When no schedule is supplied, the constructor creates a new Schedule.

readonlyrepeat: boolean

View source

Whether the runner schedules another run after this executable runs.

It defaults to true. Set it to false for a one-shot executable.

readonlydelay: number

View source

Delay before the first run and between repeated runs.

The runner interprets this value in its own time units. It defaults to 0.

readonlydefaultSystemGroup: ConstructorFn

View source

Optional default group label for callbacks on this schedule.

Callbacks without an explicit group use this label as their fallback. It is undefined when no default group was configured.

readonlyworld: ConstructorFn

View source

Constructor identifying the target world for this schedule.

The runner resolves it to the world that receives the schedule’s callbacks.

readonlysourceWorld: SourceWorldType

View source

Constructor identifying the source world for a cross-world schedule.

Normal schedules use undefined. For a cross-world schedule, the runner resolves this label and passes the resulting world as the second callback argument to CrossWorldSchedule.

readonlyerrorHandler: object

View source

Optional handler for errors thrown by schedule callbacks.

The handler receives the normalized error and target world. When it is undefined, Schedule#run and CrossWorldSchedule#run use their default error behavior.

typeId: TypeId

View source

Returns the type ID for the executable’s schedule label.

The value is derived from label with typeid when this getter is read.

Returns

Type ID for the schedule label.