Last active
July 7, 2023 14:14
-
-
Save kaszabimre/109eb62f11ad6ba03ae85f9779eea7be to your computer and use it in GitHub Desktop.
The ReducerViewModel class wraps the state of KMM ViewModels into Combine's Published properties, enabling reactive programming and data binding on the iOS platform. V1
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
import shared | |
import Combine | |
@MainActor | |
final class ReducerViewModel<S: UiState, V: ViewModel>: ObservableObject { | |
@LazyKoin var viewModel: V | |
@Published public var state: S? | |
@Published public var error: String? | |
init() { | |
guard let reducer = (viewModel as? Reducer<S, shared.UiEvent>) else { | |
return | |
} | |
//... | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment