anvilistas / anvil-labs

MIT License
9 stars 3 forks source link

wake up the service worker #105

Closed s-cork closed 2 years ago

s-cork commented 2 years ago

A service worker seems to go dormant after a time of inactivity It will wake up when it needs to In our case when a sync event is fired But if a sync event fires from a dormant service worker our python module doesn't exist anymore

To get over this we set a dummy onsync event handler. when the service worker loads from being dormant we use the waitUntil api to effectively wait for the python module to be reloaded, and then call the real onsync event handler.

To reload the python module we store all loaded modules in indexed-db.