This is mostly a question
about the code for: https://github.com/kitasuke/SwiftUI-MVVM/blob/master/SwiftUI-MVVM/ViewModels/RepositoryListViewModel.swift
I see that you are organising bindings in Outputs and Inputs... in general you are adding a level of complexity that is very difficult to understand and read.
Take as example this step in the bindingInputs()
method:
let responseStream = responsePublisher
.share()
.subscribe(responseSubject)
and this one in the bindingOutputs()
method:
let repositoriesStream = responseSubject
.map { $0.items }
.assign(to: \.repositories, on: self)
Why don't you just merge the two writing just:
let responseStream = responsePublisher // Taken from bindingInputs()
.map { $0.items } // Taken from bindingOutputs()
.assign(to: \.repositories, on: self) // Taken from bindingOutputs()
Which is the benefit of having it done in two steps? I can't understand why putting a subject
as connection between these two parts, while you could have subscribed with the .assign
directly from the responsePublisher
.
(I took hours to understand what you were doing here :P )
thank you for sharing your code! this is one of the few examples that shows a real implementation with Combine!