【发布时间】:2018-04-13 13:22:49
【问题描述】:
我按照文档中的说明离线激活,例如:
firebase
.firestore()
.enablePersistence()
.then(() => {
console.log('offlinemode acctivated')
})
日志显示如我所料。
当像这样添加数据时:
db
.collection('foo')
.add({foo: 'bar'})
.then(docRef => {
console.log('Added Foo: ', docRef.id)
// do some stuff here with the newly created foo and it's id.
})
.catch(console.error)
.then() 和 .catch() 在离线时都不会被调用。即使在执行此回调时该对象已添加到我的离线数据库中的 foo 集合中:
db
.collection('foo')
.onSnapshot(callback)
我错过了什么吗?我希望承诺要么失败要么解决,所以我可以做出相应的反应。
【问题讨论】:
标签: javascript firebase google-cloud-firestore offline