Skip to content

Instantly share code, notes, and snippets.

@kaszabimre
Last active July 7, 2023 14:14
Show Gist options
  • Save kaszabimre/109eb62f11ad6ba03ae85f9779eea7be to your computer and use it in GitHub Desktop.
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
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