-
Type: Task
-
Resolution: Gone away
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
I have a database of ~250mb. When I open a synced realm on the client I subscribe to a class of objects and I add a listener to wait for the sync to complete.
My problem is that, on Android simulator, the subscription doesn't go on and the last state I can track is 'Pending'.
This issue seems to appears only on Android Emulator but I had the same issue, with a ~1Gb database also on a Galaxy S9. I'm worried that this isn't the best way to do initial sync but I can't find any solutions provided by Realm to such a scenario.
Code Sample
await this.susbscribeAndSyncTo(this.realm_instance.objects("Cliente"), "Cliente") // This is where the sync begin static susbscribeAndSyncTo = async (object, object_name) => { var subscription = object.subscribe() return new Promise((resolve, reject) => { subscription.addListener((subscription, state) => { if (this.checkSubscriptionState(state, object_name)) { try { subscription.removeAllListeners() } catch (e) { console.log(e.message) } resolve(true); } }) }); } static checkSubscriptionState = (state, object_type) => { switch (state) { case Realm.Sync.SubscriptionState.Creating: logIfDebug(this.DEBUG,"Creo la subscription per", object_type) // The subscription has not yet been written to the Realm break; case Realm.Sync.SubscriptionState.Pending: logIfDebug(this.DEBUG,"Attendo l'arrivo dei dati", object_type) // The subscription has been written to the Realm and is waiting // to be processed by the server break; case Realm.Sync.SubscriptionState.Complete: logIfDebug(this.DEBUG,"I dati sono sincronizzati con il server", object_type) // The subscription has been processed by the server and all objects // matching the query are in the local Realm return true break; case Realm.Sync.SubscriptionState.Invalidated: logIfDebug(this.DEBUG,"La sottoscrizione ai dati è stata invalidata", object_type) // The subscription has been removed break; case Realm.Sync.SubscriptionState.Error: logIfDebug(this.DEBUG,"C'è stato un errore nella sincronizzazione con il server", object_type) break; default: logIfDebug(this.DEBUG,"Mmmm") break; } return false }
Version of Realm and Tooling
- Realm JS SDK Version: 2.29.2
- Node or React Native: 0.60
- Client OS & Version: Android Emulator
- Which debugger for React Native: ?/None