1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 14:50:32 +05:30
yattee/Model/MenuModel.swift

22 lines
575 B
Swift
Raw Normal View History

2021-11-09 04:44:28 +05:30
import Combine
import Foundation
final class MenuModel: ObservableObject {
static let shared = MenuModel()
2021-11-09 04:44:28 +05:30
private var cancellables = [AnyCancellable]()
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() })
}
}