import { Host, useEvent } from"atomico";typeDetailClickButton= {id:number};// π declaration to associate event to JSX/TSXfunctioncomponent():Host<{onclickButton:CustomEvent<DetailClickButton>}> {// π type for detailconstdispatchEvent=useEvent<DetailClickButton >("clickButton", { bubbles:true, composed:true, });return ( <host><button onclick={() => {// π DetaildispatchEvent({id:100}); }}>button</button></host> );}
Event customization
The second parameter of useEvent allows customizing the behavior of the even:
interfaceEventInit {// Allows the event to be dispatched upstream to the node's containers. bubbles?:boolean;// Allows the event to traverse the shadowDOM event capture. composed?:boolean;// Allows the event to be canceled. cancelable?:boolean;// Allows customizing the event builder, ideal for event instance-based communication. base?:Event|CustomEvent;}