2021-11-08 23:14:28 +00:00
|
|
|
import Combine
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
final class MenuModel: ObservableObject {
|
2022-11-24 20:36:05 +00:00
|
|
|
static let shared = MenuModel()
|
2021-11-08 23:14:28 +00:00
|
|
|
private var cancellables = [AnyCancellable]()
|
|
|
|
|
2022-11-24 20:36:05 +00:00
|
|
|
init() {
|
|
|
|
registerChildModel(AccountsModel.shared)
|
|
|
|
registerChildModel(NavigationModel.shared)
|
|
|
|
registerChildModel(PlayerModel.shared)
|
|
|
|
}
|
|
|
|
|
2021-11-08 23:14:28 +00:00
|
|
|
func registerChildModel<T: ObservableObject>(_ model: T?) {
|
|
|
|
guard !model.isNil else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
cancellables.append(model!.objectWillChange.sink { [weak self] _ in self?.objectWillChange.send() })
|
|
|
|
}
|
|
|
|
}
|