Last active
February 19, 2021 10:59
-
-
Save am-MongoDB/dd6466c78cb4ade08aa508399dba1c7f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
init() { | |
loginPublisher | |
.receive(on: DispatchQueue.main) | |
.flatMap { user -> RealmPublishers.AsyncOpenPublisher in | |
self.shouldIndicateActivity = true | |
var realmConfig = user.configuration(partitionValue: "user=\(user.id)") | |
realmConfig.objectTypes = [User.self, Project.self] | |
return Realm.asyncOpen(configuration: realmConfig) | |
} | |
.receive(on: DispatchQueue.main) | |
.map { | |
self.shouldIndicateActivity = false | |
return $0 | |
} | |
.subscribe(userRealmPublisher) | |
.store(in: &self.cancellables) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment