From e93b03ddb9188dbc46c3f5759a4b39a2712f1cdb Mon Sep 17 00:00:00 2001 From: cbullinger Date: Tue, 8 Aug 2023 10:44:39 -0400 Subject: [PATCH] Apply tech review feedback --- source/sdk/kotlin/sync/background-sync.txt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/sdk/kotlin/sync/background-sync.txt b/source/sdk/kotlin/sync/background-sync.txt index 74be3a3e2bb..bdd5ef4b2c5 100644 --- a/source/sdk/kotlin/sync/background-sync.txt +++ b/source/sdk/kotlin/sync/background-sync.txt @@ -40,14 +40,14 @@ First, write the custom logic that synchronizes your realm. Treat this logic as a standalone connection to your backend. As a result, you'll need to: -- Get the Realm sync configuration for your app -- Authenticate a user to open the realm. You can use a user's cached - credentials if the user recently used the app. - -Open the realm, then use `SyncSession.downloadAllServerChanges() <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb.sync/-sync-session/download-all-server-changes.html>`__ -and `SyncSession.uploadAllLocalChanges() <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb.sync/-sync-session/upload-all-local-changes.html>`__ -to synchronize the realm fully with the backend. For more information, see -:ref:`Manage Sync Sessions `. +#. Get the Realm sync configuration for your app +#. Authenticate a user to open the realm. You can use a user's cached + credentials if the user recently used the app. +#. Open the realm, then use + `SyncSession.downloadAllServerChanges() <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb.sync/-sync-session/download-all-server-changes.html>`__ + and `SyncSession.uploadAllLocalChanges() <{+kotlin-sync-prefix+}io.realm.kotlin.mongodb.sync/-sync-session/upload-all-local-changes.html>`__ + to synchronize the realm fully with the backend. For more information, see :ref:`Manage Sync Sessions `. +#. Close the realm. You can execute this logic as a background process using a subclass of :android:`CoroutineWorker `. @@ -91,6 +91,8 @@ Put your synchronization logic in the ``doWork()`` method of your worker. } catch (e: InterruptedException) { e.printStackTrace() } + } finally { + realm.close() } return future.get() }