Skip to content

Instantly share code, notes, and snippets.

@am-MongoDB
Last active February 19, 2021 10:59
Show Gist options
  • Save am-MongoDB/dd6466c78cb4ade08aa508399dba1c7f to your computer and use it in GitHub Desktop.
Save am-MongoDB/dd6466c78cb4ade08aa508399dba1c7f to your computer and use it in GitHub Desktop.
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