GoogleChromeLabs / comlink

Comlink makes WebWorkers enjoyable.
Apache License 2.0
11.45k stars 393 forks source link

Close or Terminate events on Comlink SharedWorker proxy for cleanup on Page or SharedWorker side #554

Open sivayapps opened 3 years ago

sivayapps commented 3 years ago

When a page is closed or SharedWorker Terminated, there should be a way to notify SharedWorker for any required cleanup(in my case websocket STOMP subscriptions) When shared worker is terminated, there should be a way to reload shared worker, at least some guidance in documentation will be very helpful. I used heartbeat polling to achieve same(https://github.com/sivayapps/ws-lib), but it would be very helpful if documentation suggests any standard way of doing it with Comlink.

surma commented 3 years ago

This will be solved with the Comlink.finalizer method once I finally land #469