Lens Scripting API
    Preparing search index...

    The UpdateDispatcher manages different types of events (Update, LateUpdate, and Delayed) with priority-based execution ordering. It uses object pooling for memory efficiency and provides a safe API for scheduling, prioritizing, and removing events.

    Implements

    Index

    Constructors

    Properties

    delayedEventPool: ObjectPool<DispatchedDelayedEvent> = ...
    delayedEventsHeap: BinaryHeap<DispatchedDelayedEvent> = ...
    lateUpdateEventPool: ObjectPool<DispatchedUpdateEvent> = ...
    lateUpdateEvents: DispatchedUpdateEvent[]
    mainLateUpdateEvent: SceneEvent
    mainUpdateEvent: SceneEvent
    priorityChangePool: ObjectPool<PendingPriorityChange> = ...
    updateEventPool: ObjectPool<DispatchedUpdateEvent> = ...
    updateEvents: DispatchedUpdateEvent[]

    Methods

    • Creates a delayed event that will be called after a specified time. Events are removed from the dispatch queue after firing. To reuse an event, keep a reference and call resetDelayedEvent(). If delayTimeSeconds is negative, the event is created but not scheduled to run, resetDelayedEvent() must be called.

      Parameters

      • name: string

        Descriptive name for the event for debugging purposes.

      • Optionalcallback: () => void

        Optional callback to automatically bind to the event.

      • delayTimeSeconds: number = -1

        The time in seconds to wait before firing the event, or negative to create without scheduling.

      Returns DispatchedDelayedEvent

      The created delayed event.

    • Creates an event that fires during the LateUpdate phase (after all Update events). Higher priority values (larger numbers) will be processed earlier in the late update cycle.

      Parameters

      • name: string

        Descriptive name for the event for debugging purposes.

      • Optionalcallback: () => void

        Optional callback to automatically bind to the event

      • priority: number = DEFAULT_PRIORITY

        Optional priority value (default: 0). Higher values run first.

      Returns DispatchedUpdateEvent

      The created late update event.

    • Creates an event that fires during the Update phase. Higher priority values (larger numbers) will be processed earlier in the update cycle.

      Parameters

      • name: string

        Descriptive name for the event for debugging purposes.

      • Optionalcallback: () => void

        Optional callback to automatically bind to the event

      • priority: number = DEFAULT_PRIORITY

        Optional priority value (default: 0). Higher values run first.

      Returns DispatchedUpdateEvent

      The created update event.

    • Returns void

    • Schedules a callback to be executed on the next frame.

      Parameters

      • name: string

        Name for the event (useful for debugging)

      • callback: () => void

        The function to execute on the next frame

      Returns DispatchedDelayedEvent

      The created delayed event, which can be cancelled with removeEvent if needed

    • Returns void

    • Returns void

    • Reschedules a delayed event with a new delay time. If the event is currently scheduled, it will be removed from the heap first. If delayTimeSeconds is negative, the event is unscheduled without being rescheduled.

      Parameters

      • event: DispatchedDelayedEvent

        The delayed event to reschedule.

      • delayTimeSeconds: number = -1

        The new time in seconds to wait before firing the event, or negative to unschedule without rescheduling.

      Returns void

    • Changes the priority of an existing late update event. The event will be reordered in the execution sequence according to its new priority.

      Parameters

      • event: DispatchedUpdateEvent

        The late update event to modify.

      • priority: number

        New priority value. Higher values run first.

      Returns void

    • Changes the priority of an existing update event. The event will be reordered in the execution sequence according to its new priority.

      Parameters

      • event: DispatchedUpdateEvent

        The update event to modify.

      • priority: number

        New priority value. Higher values run first.

      Returns void