Register Hooks
Register Hooks
Every time the Register changes an event is emitted with the new Register ID.
Data Structure
The data attribute of the event will have the following structure:
{
"event_name": "register:set",
"data": {
"register_id": "a604d16b-a999-8748-11e6-9a4e7ba6e8d3",
},
"source": "Vend Client API"
}
Event Handling
Here's an example of how a browser extension can subscribe to this event and perform actions based on it:
window.addEventListener('message', event => {
let eventData
try {
eventData = JSON.parse(event.data)
} catch (e) {
// @todo handle/log error
return
}
if (eventData.event_name === 'register:set') {
const registerId = eventData.data.register_id
// @todo do stuff with registerId
}
})
Updated about 2 months ago