Skip to content

connected

connected is a DOM event that occurs whenever the toggle button fires the connectedCallback Lit lifecycle method.

Event body

The connected body has a ITargetToggleButton type which represents the details of a toggle button that dispatched the event. It is optional so it might not exist.

Example

In this example we listen to connected event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    document.addEventListener('connected', ({ detail }) => {
        console.log(detail.target, ' has been connected');
    });
});