Support Staff2 Posted by creynders on 05 Aug, 2011 09:11 AM
IMO it certainly is the views responsibility. That's what views
are for: displaying data.
In general however I pass the loader's content to the view not the
loader itself and clean up all loader instances since they are no
In short: a service controls the loaders, when they (or one of
them, depends on the use case) finish loading, their content is
sent as a payload with an event, picked up by the interested
mediator and passed to its corresponding view. The view is
responsible for displaying the image and removing it when
In general however I pass the loader's content to the view not
the loader itself and clean up all loader instances since they are
no longer needed.
Do you mean that you pass the loader.content to the view as the
event payload? I'm unclear on that. If your service clears up the
unneeded loaders, since, in your example, they are a by-product and
need to be discarded, like a rocket booster, then how and who
controls the removal of the content itself on the view.
So, you're passing the images in the event, and storing them in
your view, or do you have reference to them in your model somewhere
as well? What if you'd need to reposition them later, who keeps
state (my original question)?
Support Staff6 Posted by creynders on 07 Aug, 2011 07:03 AM
Short answer: the view keeps state, since (in this case) it
concerns only view state.
In most cases the view manages and stores position, alpha, etc,
since this is explicit presentation data. There's no need to create
separate models and make your application unnecessarily complex.
However there are a few situations in which I would store view
state in models:
if the view state is shared among several views or needs to be
persistent between view display cycles.
if the view state needs to be accessed by other framework
if view state is configurable
An example would be an image editing application, since the view
state is actually application state. But even then I wouldn't store
ALL view state in models, just the data that falls under above 3