ViewModel의 타입을 정해야할 필요가 있었다.
https://github.com/boostcampwm-2024/iOS06-molio/pull/17
https://hyun-je.github.io/ios/2019/04/13/one_way_data_stream_viewmodel.html
protocol ViewModelType {
associatedtype Input
associatedtype Output
func transform(from input: Input) -> Output
}
모든 ViewModel
은 ViewModelType
을 따라야 하는데 이 때 Input
과 Output
타입 내의 프로퍼티는 var
대신 let
을, Subject
(또는 Relay
) 대신 Observable
만 사용하도록 한정한다.
이를 통해 ViewModel
에서 의도한 Input
과 Output
의 데이터 방향성을 View
에서 오용하는 것을 방지할 수 있다.
https://dev-with-precious-dreams.tistory.com/227