Skip to content
This repository was archived by the owner on Oct 9, 2024. It is now read-only.

Commit 6354b9d

Browse files
committed
feat(composables): ✨ add useEventListener
1 parent 4c8d198 commit 6354b9d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

composables/useEventListener.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default function useEventListener(target: EventTarget, type: string, callback: EventListenerOrEventListenerObject | null) {
2+
onMounted(() => target.addEventListener(type, callback));
3+
onUnmounted(() => target.removeEventListener(type, callback));
4+
}

0 commit comments

Comments
 (0)