Loading Popups

callanto's Avatar

callanto

01 Feb, 2012 11:50 PM

Hi,

Is there a way in RL that we can show a loading popup by instantiating all the events at startup in one class e.g GetUserEvent(), GetSettingsEvent() etc.. and removed once they are loaded?

  1. Support Staff 2 Posted by Ondina D.F. on 02 Feb, 2012 11:12 AM

    Ondina D.F.'s Avatar

    Hi Vijay,

    Is there a way in RL that we can show a loading popup by instantiating all the events at startup in one class e.g GetUserEvent(), GetSettingsEvent() etc.. and removed once they are loaded?

    • Are you asking how to remove events’ listeners?

    You can “unmap” the listeners in the handler method of the mapped event, for example in a Mediator:

    
    override public function onRegister():void
    {
    eventMap.mapListener(eventDispatcher, SomeModelEvent.DATA_UPDATED, onDataUpdated, SomeModelEvent);
    }
    
    protected function onDataUpdated(event:SomeModelEvent):void
    {
    view.setListDataProvider(event.someUpdatedData);
    eventMap.unmapListener(eventDispatcher, SomeModelEvent.DATA_UPDATED, onDataUpdated, SomeModelEvent);
    }
    
    • Are you asking how to unmap a Command triggered by an event?

    If you mapped a command like this:
    commandMap.mapEvent(SomeServiceResultEvent.DATA_RECEIVED, SomeServiceResultCommand, SomeServiceResultEvent);

    you can “unmap” it like this:
    commandMap.unmapEvent(SomeServiceResultEvent.DATA_RECEIVED, SomeServiceResultCommand, SomeServiceResultEvent);

    or if you map the command with oneshot (last parameter) set to true, the unmapping occurs automatically after execution:
    commandMap.mapEvent(SomeServiceResultEvent.DATA_RECEIVED, SomeServiceResultCommand, SomeServiceResultEvent, true);

    org.robotlegs.core.ICommandMap.mapEvent(eventType:String, commandClass:Class, eventClass:Class=null, oneshot:Boolean=false):void

    Did this answer your question?

  2. Support Staff 3 Posted by Ondina D.F. on 04 Feb, 2012 10:27 AM

    Ondina D.F.'s Avatar

    I answered your question while having a fever, and obviously I missed the point.
    You were talking about instantiating events, and that was confusing, because you don't instantiate events. You dispatch an event, that either triggers a Command, or a handler in a class that has registered a listener for it.
    So, probably, your question was:
    1. How to remove event listeners after closing a pop up?

    or

    2.How to remove a pop up after the loading of data has completed?

    Answers:

    1.In case the Mediator of the pop up has registered events' listeners in its onRegister(), they will be removed automatically when the mediator is unregistered(removed) from the framework.
    So, when you close the pop up, the view dispatches an event. The mediator listens to it:
    eventMap.mapListener(view, PopUpEvent.CLOSE_POPUP, onClosePopup);
    and in
    protected function onClosePopup(event:PopUpEvent):void
    {

    mediatorMap.removeMediator(this);
    }

    2.When you open the pop up its Mediator registers a listener for an event, say ResourceEvent.LOADING_COMPLETE, in its onRegister() method.

    eventMap.mapListener(eventDispatcher, ResourceEvent.LOADING_COMPLETE, onLoadingComplete);

    When a service or a model dispatches this event the popup Mediator does this:
    protected function onLoadingComplete(event:ResourceEvent):void
    {

    view.closePopUp();
    mediatorMap.removeMediator(this);
    }

    PopUpView:
    public function closePopUp
    {

    PopUpManager.removePopUp(this);
    }

    Info about pop up mediation:
    http://knowledge.robotlegs.org/kb/reference-mvcs-implementation/how...

    I hope I've got it right this time ;)

  3. Ondina D.F. closed this discussion on 29 Feb, 2012 11:16 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac