-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancing RealmResults & RealmObject notifications #1809
Conversation
Hi @rgrinberg |
@realm/java |
@@ -1,3 +1,6 @@ | |||
0.87.0 | |||
* BREAKING CHANGE: Realm.addChangeListener, RealmObject.addChangeListener and RealmResults.addChangeListener will throw an IllegalStateException when invoked on a non-Looper thread. This is to prevent registering listeners that will never be invoked (since we rely on Handler/Looper). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the comment in ()
...but not a big issue
@@ -826,9 +828,16 @@ public void removeChangeListeners() { | |||
* Notifies all registered listeners. | |||
*/ | |||
void notifyChangeListeners() { | |||
realm.checkIfValid(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is checked before calling this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notifyChangeListeners
is always in a safe path (called internally) or preceded by a check realm.checkIfValid()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Mind-melting to read 2000 lines of unit tests, but love the thoroughness of them. Generally looks good, mostly comments about style issues. I am a bit concerned about the complexity of the implementation though, but in general there is a lot of comments so that is good. Would it make sense to add a high-level description on how async work in general on the HandlerController (since that is the central class) akin to what was done for https://github.com/realm/realm-java/blob/master/realm/realm-annotations-processor/src/main/java/io/realm/processor/RealmProcessor.java ? |
bool valid = (TBL(nativeTablePtr) != NULL); | ||
if (valid) { | ||
if (!TBL(nativeTablePtr)->is_attached()) { | ||
ThrowException(env, TableInvalid, "The Realm has been closed and is no longer accessible"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
at the end of message.
Really like the refactoring of HandlerController. HandlerController could probably use an extended description of what is happening, but it doesn't have to be part of this PR. 👍 |
@@ -64,6 +65,11 @@ public DynamicRealmObject(RealmObject obj) { | |||
this.row = (row instanceof CheckedRow) ? (CheckedRow) row : ((UncheckedRow) row).convertToChecked(); | |||
} | |||
|
|||
DynamicRealmObject(BaseRealm realm, String className) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can remove the argument of realm
since it will be assigned by RealmQuery.
If a Is that the intended behavior? |
Should we document that the dynamic async query and changing schema don't work at the same time? |
}); | ||
|
||
TestHelper.awaitOrFail(signalTestFinished); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we call handlerThread.quitSafely(); handlerThread.join()
to quit the thread before returning the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the handlerThread
is not shared/reused between tests it will be GC'ed
@nhachicha I reviewed and put some questions. |
@realm/java |
👍 |
63648bb
to
d18b97d
Compare
👍 |
squashed commits |
Enhancing RealmResults & RealmObject notifications
findFirstAsync
was not rerunning the query if the initial value was emptyRealmResults
&RealmObject
RealmObject
callbacks are failing, we're waiting for Expose privatem_version
for table realm-core#1323 implementation