Created
June 26, 2018 08:05
-
-
Save maltebucksch/6f3a1dfe9b3f9a095dca884df9881266 to your computer and use it in GitHub Desktop.
Realm Sync Service: Sync-Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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