我正在使用 Firebase JS SDK。每当我为节点(带有事务)设置一个值时,该节点上的“value”事件就会被触发(甚至在调用事务回调之前也是如此。
我发现这个功能真的很烦人(尽管在其他一些情况下这可能很方便)。我可以关闭此本地同步功能吗?
最佳答案
您可以通过为 applyLocally
参数传入 false
来防止乐观触发事务
的本地事件。请参阅https://www.firebase.com/docs/web/api/firebase/transaction.html
transaction(updateFunction, [onComplete], [applyLocally])
applyLocally Boolean *optional
By default, events are raised each time the transaction update function runs. So if it is run multiple times, you may see intermediate states. You can set this to false to suppress these intermediate states and instead wait until the transaction has completed before events are raised.
关于javascript - 我们可以关闭 Firebase (JavaScript) 本地同步吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31502661/