Skip to content

How to react to embed state with lifecycle events

Overview

qlik-embed emits lifecycle events that let your host application react to the embedded UI’s rendering stages. Use them to hide a custom loading skeleton once content appears, enable or disable your own controls based on embed state, synchronize sheet navigation with your router or URL, and measure render performance. Without these events you would be forced to rely on timers or polling.

Lifecycle events report on render and navigation state. To react to data and selection state (for example, when a user makes a selection), use the imperative refApi instead.

Prerequisites

  • A working qlik-embed instance with authentication configured. See Connect with qlik-embed.

  • Minimum package versions:

    PackageVersion
    @qlik/embed-web-components1.7.0
    @qlik/embed-react2.5.0
    @qlik/embed-svelte1.1.0
    @qlik/embed-runtime1.6.0

Event reference

CallbackUIsWeb component eventdetail payload
onReadyAllqlik-embed:ready(none)
onSheetChangedclassic/appqlik-embed:sheet-changed{ sheetId: string }
onSheetReadyclassic/appqlik-embed:sheet-ready{ sheetId: string }
onRenderedclassic/chart(callback only)(none)

In web components, events are dispatched on the <qlik-embed> element and carry their data in event.detail. In React and Svelte, you pass a callback prop that receives the payload as its first argument. onRendered is available only as a callback prop; it has no corresponding DOM event.

Steps

Step 1: React to first render with onReady

onReady fires once, when the embedded UI finishes its first render. It is available on every UI. This is the moment to hide a loading skeleton or enable controls that depend on the embed being visible.

Note

onReady fires once per mount. If you remove the element from the DOM and add it back, a new mount occurs and the event fires again.

Step 2: Track sheet navigation in classic/app

onSheetChanged fires each time the user navigates to a different sheet, and onSheetReady fires once that sheet has finished rendering. Both carry the new sheetId. Use onSheetChanged to update your URL and show a transient loading indicator, and onSheetReady to re-enable controls once the content is visible. These events are emitted only by classic/app.

Step 3: Detect chart render with onRendered

onRendered fires after a classic/chart renders or re-renders. It does not fire while the chart is waiting for an update, for example after a selection. It is a callback prop only: there is no corresponding DOM event, so it is unavailable when you attach listeners to a web component element.

Verification

To confirm your listeners are wired correctly, log each event and watch the browser console as the embed loads and you navigate between sheets. You should see qlik-embed:ready fire exactly once on first render, followed by a qlik-embed:sheet-changed and qlik-embed:sheet-ready pair each time you switch sheets in a classic/app embed.

Events are non-bubbling

Lifecycle events do not propagate up the DOM. Attach listeners directly to the <qlik-embed> element. Event delegation on a parent container will not receive them.

Other events on the DOM surface

The four callbacks above are the typed lifecycle events, but some UIs emit additional events on the same qlik-embed:* DOM surface. For example, insights/feed-cards can emit qlik-embed:app-navigate-requested. See the events reference for the full list of events per UI.

Was this page helpful?