Re:Server-Sent Events (SSE) Are Underrated
by Keithamus on Thursday December 26, 2024 @01:14PM
(#42516724)
BroadcastChannel is a better solution for a couple of reasons. Service Workers are better at intercepting network requests and returning items from a cache, there’s some amount of additional effort to do work outside of that. The other thing is they’re a little more difficult to set up. A broadcast channel can be handled in a couple lines of code, easily debuggable as they run on the main thread, and they’re more suited to the purpose.
[ Parent
| on HN ]
Re:Server-Sent Events (SSE) Are Underrated
by fitsumbelay on Thursday December 26, 2024 @03:08PM
(#42517401)
agreed. Workers was one of my first thoughts but I think BroadcastChannel delivers with much lower LOE
Re:Server-Sent Events (SSE) Are Underrated
by nchmy on Friday December 27, 2024 @03:47AM
(#42520785)
Weblocks (https://developer.mozilla.org/en-US/docs/Web/API/Web_Locks_A...) are an even better way to do this than Broadcast Channel
Re:Server-Sent Events (SSE) Are Underrated
by b4ckup on Friday December 27, 2024 @05:21AM
(#42521174)
I disagree. You can just postMessage to communicate with the service worker and therefore I imagine the code using broadcast channel to be actually quite similar.
About debugging, service workers are easily debuggable, though not on the main thread as you already mentioned.