Hi Michael, thanks for writing.
I agree with you when you say that ViewModels should not be protocol.
In this case, I'm not applying any UI pattern. This simple example is not an MVVM application. I have seen these objects used in that way in different projects, therefore I decided to go deeper into the topic and to write an article about that, in a humble attempt to prevent people from writing poor code.
That said, I'm not fully convinced about your point. The Generator in the article is not a ViewModel. It is a plain Service, which provides a function to retrieve an Int. In another context, it could fetch the next integer from a backend, for example, but we don't want its interface to change.
If I would implement the same code using MVVM, I would create a specific ViewModel for my ContentView in which we can inject the generator service dependency.
Does that make sense? I tried to keep the article as simple as possible and perhaps that is why it could have been misinterpreted. What do you think?
Thanks again for taking the time to write this comment.
Best regards,
Riccardo.