The view model is responsible for coordinating that request-response chain. The details of it should live in the model.
Conversation
What if the state machine related to that network request has a different lifespan than the UI related to it?
1
These questions are hard to discuss in the abstract. That Can Be Represented, but It Depends On What The Request Is.
2
Sure. Broadly, my concern is that the approach you suggest will lead to lots of stateful effects living in the view model.
1
Yes—in many ways, that’s the point.
3
e.g. a presentation-oriented transformation of a model value to some view-appropriate value.
1
Ours contain logic like that too. It’s unfortunate, but I rationalize it as:
1
Consumers of the view model (views, basically) should be agnostic as to whether a particular transformation is stateful.
2
I'm not worried about the transformations; I'm worried about the event handlers. :/
1
Event handlers are just another form of input. View models transform all of these inputs into data for presentation.
2
Replying to
Sometimes they transform those inputs into data; sometimes they perform I/O.
I… I don't think that's helpful in this discussion. ;)
1
Show replies

