Widget
Handle widget destruction with ON_BORDA_DESTROY and interactions with ON_CLOSE_CLICK and ON_OVERLAY_CLICK.
Widget events fire for structural lifecycle and user interactions with the overlay and close button. They carry no payload and require no arguments in the handler.
Events
| Event | String value | When |
|---|---|---|
ON_BORDA_DESTROY | borda:on-destroy | Widget is about to be destroyed, before cleanup |
ON_CLOSE_CLICK | close:click | Close button is clicked |
ON_OVERLAY_CLICK | overlay:click | Overlay backdrop is clicked or activated via Enter/Space |
Usage
import { BordaEvent } from '@retoo/borda';
instance.api.events.on(BordaEvent.ON_BORDA_DESTROY, () => {
console.log('Widget is being destroyed');
});
instance.api.events.on(BordaEvent.ON_CLOSE_CLICK, () => {
console.log('Close button clicked');
});
instance.api.events.on(BordaEvent.ON_OVERLAY_CLICK, () => {
console.log('Overlay backdrop clicked');
});
Unsubscribing
Pass the same handler reference to off():
const onDestroy = () => console.log('Destroyed');
instance.api.events.on(BordaEvent.ON_BORDA_DESTROY, onDestroy);
// Later
instance.api.events.off(BordaEvent.ON_BORDA_DESTROY, onDestroy);
Notes
ON_BORDA_DESTROYfires before cleanup. After this event, the event emitter is cleared and all handlers are removed automatically.ON_CLOSE_CLICKandON_OVERLAY_CLICKare user interaction events — they fire regardless of whether the tour has a close handler configured.