4 ms·
You can easily multiplex data over one connection/event stream. You can design your app so that it only uses one eventstream for all events it needs to receive.
by jesprenj 2y ago
You can easily multiplex data over one connection/event stream. You can design your app so that it only uses one eventstream for all events it needs to receive.
- raggi 2y agoThis, it works well in a service worker for example.
- nikeee 2y agoHow does this work with a service worker? I've only managed to do this via SharedWorker (which is not available on Chrome on Android).
- raggi 2y agoYou can just open a stream in the service worker and push events via postMessage and friends. Another nice thing to do is to wire up a simple filesystem monitor for all your cached assets that pushes path & timestamp events to the service worker whenever they change, then the service worker can refresh affected clients too (with only a little work this is endgame livereload if you’re not constrained by your environment)
- tomsmeding 2y agoThe caniuse link in the OP, under Known Issues, notes that Firefox currently does not support EventSource in a service worker. https://caniuse.com/?search=EventSource https://caniuse.com/?search=EventSource