Is there a way to perform an action before closing the web worker?

I am writing an event log using web workers to process it in a secondary process. An employee collects events locally and then sends them as a batch every few seconds.

I need a way to send any unsent batches if the browser or tab closes. Is there a way for a web artist to listen to something like an event onclose?

I understand that I can do this in the application itself, but the log is a node package that will be used in several places, and I would prefer not to make the front part responsible for cleaning the event log.

+4
source share
2

-, , " " " ", . , , , .

+2

, self.onclose = function() { ... };, , . . , WorkerGlobalScope. WorkerGlobalScope.self , onclose().

, API . , , ( , Microsoft IE/Edge). - - , , , @T.J. , .

+2

All Articles