2021-11-09 04:44:28 +05:30
|
|
|
import Combine
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
final class MenuModel: ObservableObject {
|
2022-11-25 02:06:05 +05:30
|
|
|
static let shared = MenuModel()
|
2021-11-09 04:44:28 +05:30
|
|
|
private var cancellables = [AnyCancellable]()
|
|
|
|
|
2022-11-25 02:06:05 +05:30
|
|
|
init() {
|
|
|
|
registerChildModel(AccountsModel.shared)
|
|
|
|
registerChildModel(NavigationModel.shared)
|
|
|
|
registerChildModel(PlayerModel.shared)
|
|
|
|
}
|
|
|
|
|
2021-11-09 04:44:28 +05:30
|
|
|
func registerChildModel<T: ObservableObject>(_ model: T?) {
|
|
|
|
guard !model.isNil else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
cancellables.append(model!.objectWillChange.sink { [weak self] _ in self?.objectWillChange.send() })
|
|
|
|
}
|
|
|
|
}
|