Company Switcher Data & Events
The Company Switcher drop-in uses the event bus to emit and listen to events for communication between drop-ins and external integrations.
Version: latest
Events reference
| Event | Direction | Description |
|---|---|---|
| checkout/initialized | Listens | Fired by Checkout (checkout) when the component completes initialization. |
| checkout/updated | Listens | Fired by Checkout (checkout) when the component state is updated. |
| company/updated | Listens | Fired by Company (company) when the component state is updated. |
| companyContext/changed | Emits and listens | Triggered when a change occurs. |
Event details
The following sections provide detailed information about each event, including its direction, event payload, and usage examples.
checkout/initialized (listens)
Fired by Checkout (checkout) when the component completes initialization.
Event payload
nullUsage
Listen to this event in your storefront:
import { events } from '@dropins/tools/event-bus.js';
const checkoutInitializedListener = events.on('checkout/initialized', (data) => { console.log('checkout/initialized event received:', data); // Add your custom logic here});
// Later, when you want to stop listeningcheckoutInitializedListener.off();checkout/updated (listens)
Fired by Checkout (checkout) when the component state is updated.
Event payload
nullUsage
Listen to this event in your storefront:
import { events } from '@dropins/tools/event-bus.js';
const checkoutUpdatedListener = events.on('checkout/updated', (data) => { console.log('checkout/updated event received:', data); // Add your custom logic here});
// Later, when you want to stop listeningcheckoutUpdatedListener.off();company/updated (listens)
Fired by Company (company) when the component state is updated.
Event payload
Usage
Listen to this event in your storefront:
import { events } from '@dropins/tools/event-bus.js';
const companyUpdatedListener = events.on('company/updated', (data) => { console.log('company/updated event received:', data); // Add your custom logic here});
// Later, when you want to stop listeningcompanyUpdatedListener.off();companyContext/changed (emits and listens)
Triggered when a change occurs.
Event payload
string | nullUsage
Listen to this event in your storefront:
import { events } from '@dropins/tools/event-bus.js';
const companyContextChangedListener = events.on('companyContext/changed', (data) => { console.log('companyContext/changed event received:', data); // Add your custom logic here});
// Later, when you want to stop listeningcompanyContextChangedListener.off();