fix: use singleton AppContext to workaround reentry problem

This commit is contained in:
CMK 2022-11-23 14:16:28 +08:00
parent 0d01e2ad23
commit 366287a9f8
2 changed files with 14 additions and 2 deletions

View File

@ -115,6 +115,10 @@ public class AppContext: ObservableObject {
.store(in: &disposeBag) .store(in: &disposeBag)
} }
deinit {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
}
} }
extension AppContext { extension AppContext {

View File

@ -21,7 +21,7 @@ final class ShareViewController: UIViewController {
var disposeBag = Set<AnyCancellable>() var disposeBag = Set<AnyCancellable>()
let context = AppContext() let context = AppContext.shared
private(set) lazy var viewModel = ShareViewModel(context: context) private(set) lazy var viewModel = ShareViewModel(context: context)
let publishButton: UIButton = { let publishButton: UIButton = {
@ -64,6 +64,10 @@ final class ShareViewController: UIViewController {
return label return label
}() }()
deinit {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
}
} }
extension ShareViewController { extension ShareViewController {
@ -325,3 +329,7 @@ extension ShareViewController {
case missingAuthentication case missingAuthentication
} }
} }
extension AppContext {
static let shared = AppContext()
}