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.

Question about events with no listeners

See original GitHub issue

Hi! First of all, thanks for this nice lib 😃 I have a question: what happens, when you call an event and there are no listeners on its slot? It would be useful to describe that in the readme.

From what I tested, the promise returned by the event call just waits indefinitely. Is this your designed behavior, so a listener can still connect while the message is awaiting on the channel? If so, a nice feature would be to add an “instant delivery” mode, configured e.g. in an optional params object to the slot<Type>() function, where the call would fail (and reject the promise) if there are no connected listeners on that slot.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
pyrhocommented, Nov 15, 2018

Hi! First of all, thanks for this nice lib 😃

Thank you 😃

what happens, when you call an event and there are no listeners on its slot?

This is indeed the intended behavior as described in the comments of Slot.ts, here and here. An addition to the readme to explain this behavior would be nice indeed.

a nice feature would be to add an “instant delivery”

Agreed that this could be a useful addition. We don’t need it right now in our current setup though so it’s not going to rank high in our backlog. But we would happily accept a pull request wink 😃

0reactions
jacobsmithcommented, Jan 21, 2021

@mikkel-labelbox did you ever come up with a solution? I think I’m trying to accomplish what you’ve described here and would love any pointers (:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Event listeners not working? 3 key areas to troubleshoot
Are your event listeners not working as you'd expect? Here are 3 key areas to troubleshoot to help you get everything triggering as...
Read more >
Are JavaScript events always executed even if there is no one ...
Lets say "mousemove", I move the mouse but there are no listeners in the whole app, will the browser still construct a new...
Read more >
Implement event-dispatcher - JS Vault
Question. Implement an Event dispatcher which has a way to add listener, remove listeners and dispatch events. EventDispatcher.addEventListener().
Read more >
EventTarget.addEventListener() - Web APIs | MDN
Events that are bubbling upward through the tree will not trigger a listener designated to use capture. Event bubbling and capturing are two ......
Read more >
How to ensure an event listener is only fired once in JavaScript
Sometimes, we only need to listen once for an event. Imagine that we have a link to a file in the cloud that...
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