You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What would you suggest for trigger a sync from a class which is not AppDelegate?
I'm not sure if I should create a shared instance or use the NotificationCenter or if I have to import SyncKit and create an instance from CloudKitSynchronizer in every class where I interact with Realm.
Your examples do not show something like this.
I would appriciate, if you have a best practice for that.
The text was updated successfully, but these errors were encountered:
Hey @teawithfruit, generally you want to create one synchronizer per model, so if you're using Core Data you would have one synchronizer for your managed object context, and if you're using Realm you would have one synchronizer for your entire realm.
I would recommend creating your synchronizer once (I use the AppDelegate in the example), then pass it to each controller that needs it using dependency injection (here), so they can trigger synchronisation.
In another app of my own I use a protocol like this
And then implement it in a class that owns the synchronizer but doesn't expose it. So the rest of the app is fully agnostic to the technology that's being used to synchronize data.
In the case of the example app it uses VIPER and sets up all dependencies in the App Delegate, but I could give more specific advice depending on how you're architecting your app.
What would you suggest for trigger a sync from a class which is not AppDelegate?
I'm not sure if I should create a shared instance or use the NotificationCenter or if I have to import SyncKit and create an instance from CloudKitSynchronizer in every class where I interact with Realm.
Your examples do not show something like this.
I would appriciate, if you have a best practice for that.
The text was updated successfully, but these errors were encountered: