Handling events
The event handlers can be used from the component instance its nomenclature is the same as used in addEventListener(), however, they must end with a $ symbol, the arguments received also follow those of addEventListener():
import { _ } from "bemtv";
const { click$, mouseover$, $ } = _`Counter`({ count: 0 });
click$(() => $.count++, { capture: true });
mouseover$(() => console.log("Hey!"));Bemtv will manage and add them to the first element it finds in the template.
To remove just call the returned function:
import { _ } from "bemtv";
const { click$ } = _`Hey`();
const removeClickListener = click$(() => {});
removeClickListener();Last updated