Skip to content

Commit

Permalink
Apply tech review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cbullinger committed Aug 8, 2023
1 parent 9f9f779 commit e93b03d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions source/sdk/kotlin/sync/background-sync.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <kotlin-manage-sync-session>`.
#. 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 <kotlin-manage-sync-session>`.
#. Close the realm.

You can execute this logic as a background process using a subclass of
:android:`CoroutineWorker <reference/kotlin/androidx/work/CoroutineWorker>`.
Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit e93b03d

Please sign in to comment.