-
Notifications
You must be signed in to change notification settings - Fork 61
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
Improved subscribe API #1356
Improved subscribe API #1356
Conversation
… and NetworkTransport
# Conflicts: # packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/AppImpl.kt
# Conflicts: # CHANGELOG.md # packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/shared/SubscriptionExtensionsTests.kt
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.
Nice. Only essential thing is whether to collapse the anonymous and named variant like we have for MutableSubscriptionSet.add
? Otherwise just shattered some comments here and there.
packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/RealmResultsImpl.kt
Show resolved
Hide resolved
packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/ext/RealmQueryExt.kt
Outdated
Show resolved
Hide resolved
packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/ext/RealmQueryExt.kt
Outdated
Show resolved
Hide resolved
packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/ext/RealmQueryExt.kt
Outdated
Show resolved
Hide resolved
packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/ext/RealmQueryExt.kt
Show resolved
Hide resolved
...ync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/shared/SubscriptionExtensionsTests.kt
Outdated
Show resolved
Hide resolved
...ync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/shared/SubscriptionExtensionsTests.kt
Outdated
Show resolved
Hide resolved
...ync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/shared/SubscriptionExtensionsTests.kt
Outdated
Show resolved
Hide resolved
...ync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/shared/SubscriptionExtensionsTests.kt
Outdated
Show resolved
Hide resolved
...ync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/shared/SubscriptionExtensionsTests.kt
Outdated
Show resolved
Hide resolved
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.
Nice 🍾, I have added some minor comments and suggestions.
...ync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/shared/SubscriptionExtensionsTests.kt
Outdated
Show resolved
Hide resolved
packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/ext/RealmQueryExt.kt
Outdated
Show resolved
Hide resolved
packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/ext/RealmResultsExt.kt
Show resolved
Hide resolved
.../library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/AppConfigurationImpl.kt
Outdated
Show resolved
Hide resolved
packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/sync/Subscription.kt
Outdated
Show resolved
Hide resolved
packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/sync/WaitForSync.kt
Outdated
Show resolved
Hide resolved
packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/sync/WaitForSync.kt
Outdated
Show resolved
Hide resolved
packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/sync/WaitForSync.kt
Outdated
Show resolved
Hide resolved
@@ -320,15 +320,14 @@ class RealmTests { | |||
|
|||
@Test | |||
@Suppress("invisible_member") | |||
fun writeAfterCloseThrows() = runBlocking { | |||
fun writeAfterCloseThrows() = runBlocking<Unit> { |
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 might consider start using runTest, from kotlinx-coroutines-test
.
...ync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/shared/MutableSubscriptionSetTests.kt
Outdated
Show resolved
Hide resolved
# Conflicts: # packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionExtensionsTests.kt
# Conflicts: # packages/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/AppImpl.kt
@clementetb I should have addressed all concerns now, making this ready for round 2 🙏 |
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 great, some minor comments.
...ges/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/RealmQueryExtImpl.kt
Outdated
Show resolved
Hide resolved
@@ -30,6 +31,11 @@ import kotlin.reflect.KClass | |||
*/ | |||
public interface Subscription { | |||
|
|||
/** | |||
* An unique id, generated by Realm, that identifies this subscription. |
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.
* An unique id, generated by Realm, that identifies this subscription. | |
* A unique id, generated by Realm, that identifies this subscription. |
...ync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SubscriptionExtensionsTests.kt
Show resolved
Hide resolved
# Conflicts: # CHANGELOG.md
This PR adds a new
subscribe
method making it easier to create subscriptions from queries and query results.Since the
subscribe
methods have a high chance of being called from a UI context, they are switching to the dispatcher provided by theAppConfiguration
. This required reworking the logic around the dispatcher, as previously it was only used by the KtorNetworkTransport.Now that it can be used by all Sync APIs that want to delegate things to the background. I didn't want to use the notifier dispatcher since we risked it getting blocked by people trying to update subscriptions.
Due to 2 bugs in Coroutines, I had to bump the minimum supported version to 1.7.0: Kotlin/kotlinx.coroutines#3768