Firestore操作超时 [英] Timeout for firestore operations

查看:61
本文介绍了Firestore操作超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为 firestore 操作(如读取,写入和更新)设置超时?因为当连接不存在时..它不会触发 OnCompleteListener

How to set timeout for firestore operations like read, write and update?. Because When connection is not there.. it's not triggering OnCompleteListener

推荐答案

Firestore读写没有可配置的超时.假设连接将很快恢复,Firestore SDK将自动重试数据库操作.

There are no configurable timeouts for Firestore reads and writes. The Firestore SDK will automatically retry database operations with the assumption that connectivity will return shortly.

如果要在经过一定时间后强制运行某些代码,则必须实现自己的计时器.

If you want to force some code to run after some amount of time has elapsed, you will have to implement your own timer.

如果只想使用本地缓存的值,而不需要与服务器往返,则也可以在查询中指定缓存"的来源.例如,在Android中,使用获取(源),而不是正常的获取().

If you want to only use locally cached values rather than require a round trip with the server, you can specify a source of "cache" in the query as well. For example, in Android, use get(Source) instead of the normal get().

这篇关于Firestore操作超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆