-
Notifications
You must be signed in to change notification settings - Fork 577
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
Add Flexible Sync subscribe/unsubscribe APIs #5772
Conversation
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.
LGTM! Just have a few pondering questions/considerations
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.
It still looks good to me. I have only minor comments.
expect(this.realm.subscriptions).to.have.length(1); | ||
}); | ||
|
||
it("waits for objects to sync the first time only for different 'Results' instances", async function (this: RealmContext) { |
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.
Maybe the test title is a little confusing for me, but this means that WaitForSync
applies to the query and not to the results, am I correct?
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 due to how we determine if we should wait for sync or not. If, for instance, the subscription is not named, we check if it already exists by query like you said.
I'll modify the test description and can also add some comments in 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.
Looks good! And nice test coverage
}); | ||
|
||
expect(subs).to.have.length(1); | ||
expect([...subs][0].queryString).to.equal("age > 10"); |
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 would be equivalent and perhaps a bit simpler?
expect([...subs][0].queryString).to.equal("age > 10"); | |
const [ sub ] = subs; | |
expect(sub.queryString).to.equal("age > 10"); |
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.
That can be a small but good refactor we could add in a separate PR (perhaps for our test refactor ticket), because the previous pattern is also used in other places so would be good to change all of them together.
Co-authored-by: Kræn Hansen <[email protected]>
* main: Fix User.callFunction JSDoc to match the v11+ API (#5768) Add Flexible Sync subscribe/unsubscribe APIs (#5772) Fix warning for deprecated namespace setting method in Android (#5862) Update install-test-react-native.yml (#5848) Update package-unit-tests.yml to add ccache and ninja (#5837) Enable cleartext traffic in android test app to make tests work in release builds # Conflicts: # CHANGELOG.md
* fp/update-core-13.13: Corrected changelog Updated changelog Fix User.callFunction JSDoc to match the v11+ API (#5768) Add Flexible Sync subscribe/unsubscribe APIs (#5772) Fix warning for deprecated namespace setting method in Android (#5862) Update install-test-react-native.yml (#5848) Update package-unit-tests.yml to add ccache and ninja (#5837) Enable cleartext traffic in android test app to make tests work in release builds Removed unused Updated changelog # Conflicts: # packages/realm/bindgen/vendor/realm-core # packages/realm/src/index.ts
What, How & Why?
Additions:
Results
instance viaResults.subscribe()
and theResults.unsubscribe()
.SubscriptionOptions
can be passed toResults.subscribe()
which has been extended to include:WaitForSync
behavior specifying how to wait or not wait for subscribed objects to be downloaded before the returned promise resolves.MutableSubscriptionSet.removeUnnamed()
allowing for the removal of unnamed subscriptions only.Example
subscribe()
:Example
removeUnnamed()
:This closes #5760.
☑️ ToDos