Refactor ViewModels using Input/Output with Combine
AnasAlhasani opened this issue · comments
Anas Alhasani commented
Refactor ViewModel
to fully use combine and update views. This can be achieved using:
protocol ViewModel {
associatedType Input
associatedType Output
func transform(input: Input) -> Output
}
Then, i.e CharactersViewModel
should conform to ViewModel
generic protocol:
final class CharactersViewModel: ObservableObject {
}
extension CharactersViewModel: ViewModel {
struct Input { }
struct Output { }
func transform(input: Input) -> Output {
// code here ..
}
}