Trails Packages
    Preparing search index...

    Interface ExternalEventService

    Emits events to users of the current web component.

    Use the interface "integration.ExternalEventService" to obtain an instance of this service.

    interface ExternalEventService {
        emitEvent(name: string, detail?: unknown): void;
        emitEvent(event: Event): void;
    }

    Hierarchy (View Summary)

    Index

    Methods

    Methods

    • Emits an event to the host site as a CustomEvent.

      The detail value (if any) will be used as the custom event's detail.

      Parameters

      • name: string
      • Optionaldetail: unknown

      Returns void

      // In the application, e.g. in a service
      eventService.emitEvent("my-event", { message: "Hello World" });

      // In the host site (node is the application's web component node)
      node.addEventLister("my-event", (event) => {
      console.log(event.detail);
      })
    • Emits a prepared DOM event to the host site.

      The event will be dispatched on the web component's dom node without being altered by this service.

      You must take care to set the appropriate event options for your use case if you're using this overload (e.g. bubbles).

      Parameters

      • event: Event

      Returns void

      // You can use the CustomEvent class or your own subclass of Event
      eventService.emitEvent(new CustomEvent("my-event", {
      detail: "detail-value"
      }));