All events bubble and are composed, allowing you to listen on parent elements for convenient event delegation.
Reference Table
| Event | When it fires | Payload |
|---|
search | After the user submits a query (Enter or button) | { query } |
results | When initial results are received and rendered | { results } |
ai | When AI-scored results/recommendations arrive | { success, recommendations, results, count, maxRelevance } |
error | When a network or parsing error occurs | { error } |
Examples
Fields trimmed for brevity.
{ "query": "What is your return policy?" }
{
"results": [
{
"id": "product_123",
"name": "Product Name",
"publicUrl": "https://example.com/products/product-name",
"price": "$42.00"
}
]
}
{
"success": true,
"count": 5,
"maxRelevance": 0.92,
"recommendations": [
{
"text": "Best for small spaces",
"productIds": ["product_123"],
"relevancyScore": 0.91,
"reasoning": "Compact footprint and quiet operation"
}
],
"results": [
{ "id": "product_123", "name": "Product Name", "publicUrl": "https://example.com/products/product-name" }
]
}
{ "error": "Request timed out" }