0.2.0

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

EventString valueWhen
ON_BORDA_DESTROYborda:on-destroyWidget is about to be destroyed, before cleanup
ON_CLOSE_CLICKclose:clickClose button is clicked
ON_OVERLAY_CLICKoverlay:clickOverlay 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_DESTROY fires before cleanup. After this event, the event emitter is cleared and all handlers are removed automatically.
  • ON_CLOSE_CLICK and ON_OVERLAY_CLICK are user interaction events — they fire regardless of whether the tour has a close handler configured.