Skip to content
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

Merged
merged 1 commit into from
Dec 2, 2015

Conversation

nhachicha
Copy link
Collaborator

  • Adding support for async queries for Dynamic Realm API
  • Fixing a bug where findFirstAsync was not rerunning the query if the initial value was empty
  • Adding more tests for type-based notifications
  • Callbacks (RealmChangeListeners) are now called on both synchronous & asynchronous RealmResults & RealmObject
  • Using Table version to reduce the number of callback invocations (this will filter out all commits non impacting the query used to obtain the RealmResults/RealmObject)
  • Some tests involving RealmObject callbacks are failing, we're waiting for Expose private m_version for table realm-core#1323 implementation

@nhachicha
Copy link
Collaborator Author

Hi @rgrinberg
No since we'll be using internally a weak reference listeners for Adapter

@nhachicha
Copy link
Collaborator Author

@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).
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Collaborator Author

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()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@cmelchior
Copy link
Contributor

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");
Copy link
Contributor

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.

@cmelchior
Copy link
Contributor

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) {
Copy link
Contributor

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.

@zaki50
Copy link
Contributor

zaki50 commented Dec 1, 2015

If a DynamicRealmObject is accessed before async query is complete, getObject(String) seems to throw IllegalStateException and getList(String) seems to throw NPE.
Other getters seem to return default values (0).

Is that the intended behavior?

@zaki50
Copy link
Contributor

zaki50 commented Dec 1, 2015

Should we document that the dynamic async query and changing schema don't work at the same time?
I'd like to believe no one do that, but users do everything they can...

});

TestHelper.awaitOrFail(signalTestFinished);
}
Copy link
Contributor

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?

Copy link
Collaborator Author

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

@zaki50
Copy link
Contributor

zaki50 commented Dec 2, 2015

@nhachicha I reviewed and put some questions.

@nhachicha
Copy link
Collaborator Author

@realm/java

@cmelchior
Copy link
Contributor

👍

@zaki50
Copy link
Contributor

zaki50 commented Dec 2, 2015

👍

@nhachicha
Copy link
Collaborator Author

squashed commits

nhachicha added a commit that referenced this pull request Dec 2, 2015
Enhancing RealmResults & RealmObject notifications
@nhachicha nhachicha merged commit 59e02d1 into master Dec 2, 2015
@nhachicha nhachicha removed P1 labels Dec 2, 2015
@nhachicha nhachicha deleted the nh/fine-grained-notif branch December 2, 2015 15:52
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants