Update Store directly
Demo
Go offline, then online to see the store sync
Explanation
<div
data-store.offline='{"stuffAlreadyInStore":"this will be in the store even without network"}'
data-on-online.window="console.log('online, syncing'); $$put('/examples/offline_sync/sync', false)"
data-on-offline.window="console.log('offline')"
>
<div id="results"></div>
</div>
The .offline
attribute is used to dump the store to a datastar
key in localStorage. Any updates will be saved and reload on page refresh. To fully work this needs a service worker like workbox to be installed. To test it go to the network tab of your browser’s dev tools and toggle Online/Offline.