anvilistas / anvil-labs

MIT License
9 stars 3 forks source link

Service Workers - more support #99

Closed s-cork closed 2 years ago

s-cork commented 2 years ago

close #96, close #97, close #98

Managed to find some time last night to look at this

Have a fun working prototype here: https://anvil.works/build#clone:6KH7IIUS22JMNW54=664RQKGADXDEV6KC4XPXNMPR

Publish an enviorenment You'll need to change the env.ENDPOINT value You can install the app as PWA then upload some files, add them to IDB, sync them then repeat but go off-line close the app come on line wait a bit open the app - either the sync event will fire when you open the app, or it will have already fired while the app was off!

API Changes:

self.sync_event_handler = sync_event_handler

@self.sync_event_handler def onsync(e):

do a bunch of things when a sync event fires

...

self.onsync = onsync


This Browser API means that if the sync event handler fails the syncManager will re-register this tag 👍 
s-cork commented 2 years ago

@rhurlbatt - you might want to check out the clone in this PR which uses the features added here Some instructions above You might also want to try opening the app in multiple tabs