the*_*ace 7 javascript offline firebase google-cloud-firestore
我按照文档中所述离线激活:
firebase
.firestore()
.enablePersistence()
.then(() => {
console.log('offlinemode acctivated')
})
Run Code Online (Sandbox Code Playgroud)
日志显示如我所料。
添加数据时,如下所示:
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)
Run Code Online (Sandbox Code Playgroud)
.then()离线时也不会.catch()被呼叫。即使在执行此回调时该对象已添加到我的离线数据库中的 foo 集合中也是如此:
db
.collection('foo')
.onSnapshot(callback)
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?我预计这个承诺要么失败,要么解决,这样我就可以做出相应的反应。
| 归档时间: |
|
| 查看次数: |
1153 次 |
| 最近记录: |