waitForInitialRemoteData
Setting this will cause the Realm to download all known changes from the server the first time a Realm is opened. The Realm will not open until all the data has been downloaded. This means that if a device is offline the Realm will not open.
Since downloading all changes can be a lengthy operation that might block the UI thread, Realms with this setting enabled should only be opened on background threads.
This check is only enforced the first time a Realm is created, except if initialSubscriptions has been configured with rerunOnOpen = true
. In that case, server data is downloaded every time the Realm is opened.
If it is conditional when server data should be downloaded, this can be controlled through SyncSession.downloadAllServerChanges, e.g like this:
val user = loginUser()
val config = SyncConfiguration.Builder(user, schema)
.initialSubscriptions { realm ->
add(realm.query<City>())
}
.build()
val realm = Realm.open(config)
if (downloadData) {
realm.syncSession.downloadAllServerChanges(timeout = 30.seconds)
}
Parameters
how long to wait for the download to complete before an io.realm.kotlin.mongodb.exceptions.DownloadingRealmTimeOutException is thrown when opening the Realm.