Skip to content

Instantly share code, notes, and snippets.

@maltebucksch
Created June 26, 2018 08:05
Show Gist options
  • Save maltebucksch/6f3a1dfe9b3f9a095dca884df9881266 to your computer and use it in GitHub Desktop.
Save maltebucksch/6f3a1dfe9b3f9a095dca884df9881266 to your computer and use it in GitHub Desktop.
Realm Sync Service: Sync-Service
class SyncService {
private let realm: Realm
private let tokens: [NotificationToken]
init(modelTypes: [Syncable.Type], realm: Realm = try! Realm()) {
self.realm = realm
tokens = modelTypes.map { modelType in
modelType.registerNotificationObserver(for: realm, callback: SyncService.handleUpdate)
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment