Question

I am trying to get the publish(), handshake(), subscribe() works done in Web Worker() thread instead of UI thread. But so far no success because when I try to import by "importScripts('cometd.js')" cometd.js cannot load because cometd.js use "window" which is not available in Web Worker(). Have anyone done anything on this?

Was it helpful?

Solution

CometD callbacks, in most applications, need to modify the DOM, so it is very convenient that they are run in the UI thread.

Furthermore, CometD inner workings is completely asynchronous, so it never blocks the UI thread.

Therefore, using WebWorkers in CometD is not needed: it will complicate the CometD implementation, and I very likely also the application.

To answer your question, the option to run CometD code in WebWorkers has been considered, but eventually not implemented because it was deemed as unnecessary for the reasons above.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top