Skip to content

Instantly share code, notes, and snippets.

@kulor
Created May 3, 2018 15:02
Show Gist options
  • Save kulor/3e4d8744fb94f17314538bc6067ff57f to your computer and use it in GitHub Desktop.
Save kulor/3e4d8744fb94f17314538bc6067ff57f to your computer and use it in GitHub Desktop.
Example Redux Offline config with network detection
const reduxOfflineConfig = {
...,
detectNetwork: callback => {
setInterval(async () => {
try {
await fetch('yourbackend.com/ping', { method: 'HEAD' })
callback({
online: true
})
} catch(e) {
callback({
online: false
})
}
}, 2000)
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment