Android Realm repalce refresh with waitForChange -
after v0.91.0, deprecated methods in realm removed including refresh()
.
i've used refresh()
below make sure realm instance has up-to-date data.
public static <t> t query(realmactionwithresult<t> runnable, t defaultvalue) { realm realm = realm.getinstance(getconfiguration()); try { realm.refresh(); return runnable.run(realm); } catch (exception e) { return defaultvalue; } { realm.close(); } }
if replace refresh()
waitforchange()
, it's blocked until next change happens (of course in non-looper thread).
how can make not block current thread, pass when current realm up-to-date 1 or block if there should wait?
or if use realm above pattern (every time close it) in non-looper thread schedulers.io
in rx, realm.getinstance()
return newest snapshot because per-thread cached instance reference zero?
you don't have call refresh
right after calling getinstance()
. realm returned getinstance()
date.
Comments
Post a Comment