Skip to main content

Event System

Components communicate via DOM events that bubble up.

Core Events

EventWhenYour response
content:selectUser clicks itemHandle navigation
content:action:startAction beginsOptional: show loading
content:action:successAction completedOptional: analytics
content:action:errorAction failedShow error
data:refresh:requestComponent requests dataFetch and respond
data:refresh:doneData loaded successfullyHide loading
data:refresh:errorData load failedShow error state
ui:render:doneComponent finished post-mount async workOptional: hide loading indicator

content:* events are user interactions on content items; data:refresh:* events describe data-loading requests and outcomes.

Event Detail Structure

The campaign and voucher objects in event details are full Spaaza API objects. See API Documentation for their complete structure.

// content:select
{
campaign: { id: 4911, type: 'wallet', title: 'Points Wallet', image_link: '?campaign_id=4911' },
voucher: { id: 123, title: 'Reward' }, // if voucher clicked
item: { layoutType: 'card', type: 'campaign' },
zone: { id: 'rewards', orientation: 'vertical' },
page: { name: 'home', storeid: 3522 },
root: 'spaaza-content-item', // component that emitted the event
pageContext: 'spaaza-content-page' // top parent: page or detail
}

// content:action:start
{
action: 'wallet-value-select',
campaign_info: { campaignId: 4911, walletBalance: 150, selectedAmount: 50 },
root: 'spaaza-content-item-campaign-wallet',
pageContext: 'spaaza-content-page-detail'
}

content:select

All events include root (emitting component) and pageContext (page or detail).

Event detail contains Spaaza's default objects. See API Documentation for full object structures.

FieldDescription
campaignSpaaza's default campaign object
voucherSpaaza's default voucher object (if voucher clicked)
itemItem metadata: layoutType, type
zoneZone metadata: id, orientation
pagePage metadata: name, storeid

Action Events

content:action:start

{
action: 'wallet-value-select',
campaign_info: {
campaignId: 4911,
campaignType: 'wallet',
walletId: 4912,
walletBalance: 150,
selectedAmount: 50
},
root: 'spaaza-content-item-campaign-wallet',
pageContext: 'spaaza-content-page-detail'
}

content:action:success

{
action: 'wallet-value-select',
campaign_info: { campaignId: 4911, walletId: 4912, selectedAmount: 50 },
root: 'spaaza-content-item-campaign-wallet',
pageContext: 'spaaza-content-page-detail'
}

content:action:error

{
action: 'wallet-value-select',
campaign_info: { campaignId: 4911, walletId: 4912 },
error: 'Insufficient balance',
root: 'spaaza-content-item-campaign-wallet',
pageContext: 'spaaza-content-page-detail'
}

Action Event Types

For the full list of action types, see Operation Handling Matrix.

Data Events

These events handle communication between web components and Spaaza's controller for data fetching operations.

data:refresh:request (component requests data)

{
action: 'get-content-page', // or get-campaign, get-user-vouchers
page: { name: 'home', storeid: 3522 },
root: 'spaaza-content-page',
pageContext: 'spaaza-content-page'
}

data:refresh:done (data loaded successfully)

{
action: 'get-content-page',
page: { name: 'home', storeid: 3522 },
source: 'external',
root: 'spaaza-controller',
pageContext: 'spaaza-content-page'
}

data:refresh:error (data load failed)

{
action: 'get-content-page',
error: 'Network error',
root: 'spaaza-controller',
pageContext: 'spaaza-content-page'
}

UI Events

These events fire when a component reports a UI-level state change distinct from data loading.

ui:render:done (component fully rendered after async work)

Most components are ready as soon as their data arrives (data:refresh:done). Components that perform additional asynchronous rendering work after data arrives emit ui:render:done once that work completes. Listen to this event if you want to defer your "ready" or "hide loading" signal until the UI is visibly settled.

{
action: 'scratch-table-ready',
campaign_info: { campaignId: 4911 },
root: 'spaaza-content-item-campaign-...',
pageContext: 'spaaza-content-page-detail'
}