Skip to content

Instantly share code, notes, and snippets.

@duytq94
Last active September 8, 2020 12:40
Show Gist options
  • Save duytq94/d0de73ee43582eee05f178f01a1e6ec2 to your computer and use it in GitHub Desktop.
Save duytq94/d0de73ee43582eee05f178f01a1e6ec2 to your computer and use it in GitHub Desktop.
syncDb = () => {
this.setState({isLoading: true})
handlerSync = PouchDB.sync(remoteNoteDb, localNoteDb, {
live: true,
retry: true,
})
.on('change', (info) => {
// console.log(TAG, 'sync onChange', info)
})
.on('paused', (err) => {
// console.log(TAG, 'sync onPaused', err)
if (this.isAtCurrentScreen) {
this.getListNoteFromDb()
}
})
.on('active', () => {
// console.log(TAG, 'sync onActive')
})
.on('denied', (err) => {
// console.log(TAG, 'sync onDenied', err)
})
.on('complete', (info) => {
// console.log(TAG, 'sync onComplete', info)
})
.on('error', (err) => {
// console.log(TAG, 'sync onError', err)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment