Created
August 27, 2020 08:37
-
-
Save NewFieldForMe/63b6c4b3df9b8568d4a92bf347a9dc93 to your computer and use it in GitHub Desktop.
Combine: sink and transform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TodoListSideMenuViewModel: ObservableObject { | |
@Published var darkModeModel = DarkModeModel() | |
@Published var darkModeSystemName: String = "" | |
private var bag = Set<AnyCancellable>() | |
init() { | |
self.darkModeModel.$isDark.sink(receiveValue: { [weak self] isDark in | |
self?.darkModeSystemName = isDark ? "moon.fill" : "sun.max.fill" | |
}).store(in: &bag) | |
} | |
func switchDarkMode() { | |
darkModeModel.isDark = !darkModeModel.isDark | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment