removeEventNative is the counterpart to
addEventNative — a thin wrapper over
removeEventListener that accepts the same function-or-object
handler. Pass the exact handler reference you added. Part of
pota/use/event.
Attaches a resize listener on window and removes it later by
passing the exact same handler reference.
import { render, signal } from 'pota'
import { addEventNative, removeEventNative } from 'pota/use/event'
function App() {
const log = signal('resize to see width')
const onResize = () => log.write(`width: ${window.innerWidth}`)
addEventNative(window, 'resize', onResize)
return (
<div>
<button
on:click={() => removeEventNative(window, 'resize', onResize)}
>
remove listener
</button>
<p>{log.read}</p>
</div>
)
}
render(App)