Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

* | |

  Show Posts
Pages: [1]
1  PureMVC Manifold / Standard Version / Re: Flex Mobile ViewNavigator and PureMVC on: November 28, 2011, 09:15:45
thx for the detailed explanation.

Had some time to experiment a bit and came to more or less the same solution. I'll try to highlight the things i did different:

Remove mediators

Remove mediators when a view is removed. My thought why this is important: If you keep the mediator, you keep a reference to the view. So the view can never be garbage collected until the mediator is also removed.

In your solution, you keep the current mediator until the next time a view of the same Class is created. This implies that once your application has visited all views, you use the same amount of memory as creating all views on startup and keep a fixed reference to them.

No centralized registration of mediators

I'm registering my mediators by listening to the ElementExistenceEvent.ELEMENT_ADD events of the viewNavigator and TabbedViewNavigator.

I'm removing my mediators by listening to the ElementExistenceEvent.ELEMENT_REMOVE events.

This way, you can reuse the same View Class in for example two different ViewNavigators in one TabbedViewNavigator.

Example: You have an application with a View that can represent a list of persons: PersonListView. In one Tab you display family in a family viewNavigator, in a second tab you display friends in a friends viewNavigator, .. By splitting the registration of the mediators, you can reuse the same View: When a PersonListView view is created in the family viewNavigator, you create a family mediator which populates the view with family data. When the a PersonListView is created in the friends viewNavigator, your create a friend mediator which populates the view with friends data.

When you register your mediators in one centralized command, you can not know with what data that view should be populated.. or is there an other way to do this? If you could do this in any other way, i would prefer the centralized solution.. I don't think you can use the id property, cause there is no way to set it when you call the navigator.pushView(View) method...

EDIT: Just noticed that the third parameter of the pushView method,  'context' can be used in order to reuse view components. Going for the centralized approach..
2  PureMVC Manifold / Standard Version / Re: Flex Mobile ViewNavigator and PureMVC on: November 24, 2011, 05:46:25
I'm setting up a mobile flex iOS application with ViewNavigators. I'm used to the pureMVC framework, but i'm still not sure how to use it in combination with those ViewNavigators.

The views in the ViewNavigators are created/removed during the run of an application. This minimizes the used memory of the application. Memory use should be low since an iOS application keeps on running in the background if you exit the application. So i don't want to use the approach to create all view at startup and keep them in memory.

Did a small test, and it seems that views are not reused: each time a view is needed, a new instance is created. This means that mediators should be created and removed whenever a view is created/removed.

Is there a good way to do this?

Can the id be used to look what mediator should be created? In this case: how can we specify an id for the 'firstView' that will be created?

Or should we look at the class type of the view? I suppose this means views can not be reused within an application..
Pages: [1]