Tools for listening to events on your eitri-app coming from the main app.

You can also use this bus to implement a pub/sub pattern inside your eitri-app.

Compatibility Control

  • API LEVEL 7 - Functionality added

Hierarchy

  • EventBus

Methods

  • Unsubscribe a callback function from receiving notifications on a specific channel.

    Compatibility Control

    • API LEVEL 7 - Functionality added

    Parameters

    • channel: string

      The identifier of the channel from which to unsubscribe.

    • callback: ((data) => void)

      The callback function to be unsubscribed.

        • (data): void
        • Parameters

          • data: any

          Returns void

    Returns void

  • Clear all listeners subscribed to a specific channel.

    Compatibility Control

    • API LEVEL 7 - Functionality added

    Parameters

    • channel: string

      The identifier of the channel for which to clear all listeners.

    Returns void

  • Publish data to a specific channel, notifying all subscribed listeners.

    Compatibility Control

    • API LEVEL 7 - Functionality added

    Parameters

    • channel: string

      The identifier of the channel on which to publish the data.

    • data: any

      The data to be published to the channel's listeners.

    Returns void

  • Subscribe to notifications on a specified channel, providing a callback function to handle received messages.

    Parameters

    • channel: string

      The identifier of the channel for which you want to receive notifications.

    • callback: ((data) => void)

      The callback function that will be invoked when messages are received on the specified channel.

        • (data): void
        • Parameters

          • data: any

          Returns void

    • persistBetweenNavigations: boolean = false

      (Optional) Indicates whether the listener should persist between navigations. Default is false. If set to true, the listener will continue to receive notifications even when the eitri-app navigates between screens. If set to false, the listener will be removed during navigation transitions.

      // Subscribe to a channel and specify a callback function
      Eitri.eventBus.subscribe('myChannel', (data) => {
      // Handle the received data here
      console.log('Received data:', data);
      });

      Compatibility Control

      • API LEVEL 7 - Functionality added

    Returns void

Generated using TypeDoc