Question about events with no listeners
See original GitHub issueHi! 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:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you 😃
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.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 😃
@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 (: