klevulistendomevent
3 min
▸ KlevuListenDomEvent(klevuDomEvent, callback): () => void
Helper function to listen Klevu Dom events
import { KlevuDomEvents, KlevuListenDomEvent } from '@klevu/core'
// Event to listen
const stopListen = KlevuListenDomEvent(KlevuDomEvents.LastSearchUpdate, (event) => {
console.log('last search updated!', event.detail)
})
// stop listening
stopListen();Parameters
Name | Type | Description |
|---|---|---|
klevuDomEvent | What event to listen | |
callback | (event: Event) => void | What to do when event is fired |
Returns
fn
Function to stop listening
▸ (): void
Returns
void