如何取消Firebase setValue(待离线时) [英] How to cancel Firebase setValue while pending for completion (when offline)

查看:148
本文介绍了如何取消Firebase setValue(待离线时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想停止监听实时更改,则可以调用ref.removeAllObservers()来读取数据(如observeEventType)。但是,我找不到一个方法来中断和取消setValue(写入数据)。有一些用例,我需要取消数据的写入,而等待一段时间的互联网连接重新上线。这是可能的和如何?如果有一个写入队列,可以通过调用 FIRDatabase.purgeOutstandingWrites()来清空它。

/ code>。


I can call ref.removeAllObservers() for reading data (such as observeEventType) if I want to stop listening for real time changes. However, i cannot find a way to interrupt and cancel the setValue (writing data). There are some use case which I need to cancel the writing of data while waiting for some time for internet connection to get back online. Is it possible and how?

解决方案

If there is a write queue, you can empty it by calling FIRDatabase.purgeOutstandingWrites().

这篇关于如何取消Firebase setValue(待离线时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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