question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Event Listener Options

See original GitHub issue

It would be nice if Kefir.fromEvents supported passing event listener options to the addEventListener call underneath. For example, you may need to pass the passive flag to for touch performance reasons or want to attach to the capture phase with useCapture. Example:

document.addEventListener('touchstart', handler, {passive: true});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mAAdhaTTahcommented, Sep 21, 2017

Part of the issue with this proposal is Kefir.fromEvents isn’t for DOM events only, but also works with on / off and addListener / removeListener pairs, neither of which necessarily support this. That said, Kefir.fromEvents isn’t particularly magical. You could easily just do:

Kefir.stream(emitter => {
  target.addEventListener('click', emitter.value, { passive: true });
  return () => target.removeEventListener('click', emitter.value, { passive: true });
});
0reactions
jcbelangercommented, Sep 22, 2017

I think we all agree that Kefir.stream() is the way to go. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

EventTarget.addEventListener() - Web APIs | MDN
The method addEventListener() works by adding a function, or an object that implements EventListener , to the list of event listeners for the ......
Read more >
EventTarget.addEventListener() | Can I use... Support tables ...
The modern standard API for adding DOM event handlers. Introduced in the DOM Level 2 Events spec. Also implies support for removeEventListener ,...
Read more >
HTML DOM Document addEventListener() Method - W3Schools
Definition and Usage. The addEventListener() method attaches an event handler to a document. ; Syntax. document.addEventListener(event, function, Capture) ...
Read more >
EventTarget.addEventListener() - Web APIs
addEventListener () works by adding a function or an object that implements EventListener to the list of event listeners for the specified event...
Read more >
The addEventListener() Method – JavaScript Event Listener ...
The JavaScript addEventListener() method allows you to set up functions to be called when a specified event happens, such as when a user ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found