eligius
    Preparing search index...

    Class MutationObserverController

    Controller that observes DOM mutations on a selected element and broadcasts events.

    This controller creates a MutationObserver to monitor DOM changes (attributes, child nodes, text content) on a specified element. All detected mutations are broadcasted through the Eligius eventbus, enabling reactive behavior in response to DOM changes.

    The controller follows the standard Eligius lifecycle:

    • init(): Store configuration metadata
    • attach(): Create and start the MutationObserver
    • detach(): Disconnect the observer and clean up resources
    // JSON configuration
    {
    "systemName": "addControllerToElement",
    "operationData": {
    "controllerName": "MutationObserverController",
    "observeAttributes": true,
    "observeChildList": true,
    "observeCharacterData": false
    }
    }

    // Listen for mutations
    eventbus.on('dom-mutation', (payload: IMutationEventPayload) => {
    console.log('Mutations detected:', payload.mutations);
    });

    Hierarchy

    Index

    Constructors

    Properties

    eventListeners: TEventbusRemover[] = []
    name: string = 'MutationObserverController'
    operationData: IMutationObserverControllerMetadata | null = null

    Methods

    • Register event listener with automatic binding and cleanup tracking

      Parameters

      • eventbus: IEventbus

        The eventbus to register with

      • eventName:
            | "before-request-timeline-uri"
            | "before-request-video-url"
            | "dom-mutation"
            | "highlight-navigation"
            | "language-change"
            | "navigate-to-video-url"
            | "push-history-state"
            | "request-action"
            | "request-current-language"
            | "request-current-navigation"
            | "request-current-timeline-position"
            | "request-current-video-position"
            | "request-engine-root"
            | "request-function"
            | "request-instance"
            | "request-label-collection"
            | "request-label-collections"
            | "request-timeline-cleanup"
            | "request-timeline-uri"
            | "request-video-cleanup"
            | "request-video-url"
            | "timeline-complete"
            | "timeline-container-request"
            | "timeline-current-timeline-change"
            | "timeline-duration"
            | "timeline-duration-request"
            | "timeline-firstframe"
            | "timeline-pause"
            | "timeline-pause-request"
            | "timeline-play"
            | "timeline-play-request"
            | "timeline-play-toggle-request"
            | "timeline-request-current-timeline"
            | "timeline-resize"
            | "timeline-resize-request"
            | "timeline-restart"
            | "timeline-seek"
            | "timeline-seek-request"
            | "timeline-seeked"
            | "timeline-stop"
            | "timeline-stop-request"
            | "timeline-time"
            | "video-complete"

        Name of the event to listen for

      • handler: (...args: any[]) => void

        Event handler function (will be bound to this controller)

      Returns void

    • Attach the controller and start observing mutations. Creates MutationObserver instance and begins monitoring the target element.

      Parameters

      • eventbus: IEventbus

        Eligius eventbus for broadcasting mutation events

      Returns void

    • Register multiple event listeners at once

      Parameters

      • eventbus: IEventbus

        The eventbus to register with

      • listeners: { eventName: string; handler: (...args: any[]) => void }[]

        Array of {eventName, handler} pairs

      Returns void