return stopper function as the result of record

This commit is contained in:
Yanzhen Yu
2018-12-02 22:37:28 +08:00
parent b7e7f12d32
commit 78967192fc
3 changed files with 105 additions and 93 deletions

View File

@@ -11,8 +11,9 @@ export function on(
fn: EventListenerOrEventListenerObject,
target: Document | Window = document,
): listenerHandler {
target.addEventListener(type, fn, { capture: true, passive: true });
return () => target.removeEventListener(type, fn);
const options = { capture: true, passive: true };
target.addEventListener(type, fn, options);
return () => target.removeEventListener(type, fn, options);
}
export const mirror: Mirror = {