Pre-Condition : I have 10 Dogs stored in a Realm Server
Is there a way to know when the results are ready?
let usernameCredentials = SyncCredentials.usernamePassword(username: email, password: pass)
SyncUser.logIn(with: usernameCredentials,server: Utils.sharedInstance.serverURL) { user, error in
if error != nil {
// handle error
} else {
let config = Realm.Configuration(syncConfiguration: SyncConfiguration(user: user!, realmURL: Utils.sharedInstance.syncServerURL))
let realm = try! Realm(configuration : config)
let dogs = realm.objects(Dog.self)
print("I have : \(dogs.count) dogs")
// dogs count is 0 here
// ..............
// some time later i have the 10 Dogs
}
}
Unfortunately not at the moment. Realm's sync APIs and semantics right now are best suited for incremental sync use cases, but we're working on two features that should help address the use case you've shared.
The first is a "Download Realm" API which only makes the Realm available once its entire contents have been downloaded.
The second is "sync progress notifications", where you can register a progress update block to fire with information about how much 1) local data needs to be synced up and 2) remote data needs to be synced down.