gpt4 book ai didi

android - 检查 realmObject 是否已更新

转载 作者:行者123 更新时间:2023-11-29 01:12:54 24 4
gpt4 key购买 nike

documentation对于 realmObject.isValid() 说:

isValid() Checks if the realmObject is still valid to use i.e., the realmObject hasn't been deleted nor has the Realm been closed.

但是,对于已在另一个线程中更新的 realmObjectisValid() 会返回什么?

Realm 会更新当前线程(非更新线程)中保存的 realmObject 还是将其视为无效

文档似乎没有提供答案。

最佳答案

多线程

Will realm update the realmObject held in the current thread (non updating thread)?

答案是YES,如果在给定线程上启用了自动更新,这需要一个 Looper。这在 Threading 中有描述。部分:

There’s actually very little you need to know, or do, when working with various threads with Realm. The key takeaway here is that Realm makes it effortless to work with data on multiple threads without having to worry about consistency or performance because objects and queries are auto-updating at all times.

更新状态

But, what would isValid() return for a realmObject which has been updated in another thread?

您可以添加更新监听器,它会在数据更新时通知您的 UI 组件(例如)。这在 Notification 中有描述。部分。

关于android - 检查 realmObject 是否已更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41709981/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com