PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: amazed on October 23, 2008, 05:40:22



Title: How to remove Mediators and views
Post by: amazed on October 23, 2008, 05:40:22
I was checking the J2ME login demo and I was thinking where would be the best place and how to unload the views that are not needed.

Lets say my project is really heavy for mobile phones and I want to unload last view and its data when a new view is loaded.

To be clearer, Lets see the PrepViewCommand which creates the instances of MainScreenView before login in successful.

:
public class PrepViewCommand extends SimpleCommand implements ICommand
{
    public void execute(INotification notification)
    {
        this.facade.registerMediator(new SplashScreenMediator());
        this.facade.registerMediator(new LoginScreenMediator());
        this.facade.registerMediator(new MainScreenMediator());
    }
}

Lets say I dont want to create MainScreenMediator before login is successful and after login is done I dont want to keep LoginScreenMediator in memory which keeps LoginScreen as its member.

What should be the best practice to do so?

I hope I managed to make my question clear :)

Mazed


Title: Re: How to remove Mediators and views
Post by: dzeikei on October 27, 2008, 02:04:22
Hi im no expert in PureMVC, but I would make the startup command only load the SplashScreenMediator and LoginScreenMediator then make another command that unloads those two mediators and loads the MainScreenMediator on successful login notification.

jK