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

Pages: [1]
Print
Author Topic: A Mediator How to control multiple components ?  (Read 16936 times)
youling8088
Newbie
*
Posts: 3


View Profile Email
« on: October 11, 2009, 07:32:58 »

I encountered such a problem:
I have a view component, there is a binding of this component of the Mediator. When I register an instance of a component at the same time look into the Mediator. But when I send an announcement that not all instances of time can be received, but only registered Mediator for the first time to receive.
Who can help me to tell me what to do?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: October 13, 2009, 09:04:34 »

Forgive me, but I'm really having a hard time understanding this post. Can you rephrase please? Perhaps with code snippits pointing to the problem?

-=Cliff>
Logged
youling8088
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: October 14, 2009, 03:07:05 »

I helped in the sub-view documentation, see: "Usually only one Mediator corresponds to a View Component", so I was planning to do this part puremvc developed. Do not know if puremvc can resolve this problem.

I have a Page.as corresponding to this I wrote a PageMediator.as; each new Page () when they facade.registerMediator (new PageMediator (Page instance)); each to download data, receive the data download is complete, each update message Page instance. But the scene is only one PageMediator can receive the message.

For this to create multiple display components of the framework of how to use the puremvc development? Want to be pointing you, thank you!
---------------------------------------------------------------------------------------------------
我在次查看了帮助文档,看到:“通常一个Mediator只对应一个View Component”,所以我正打算把这一部分不用puremvc开发了。不知道puremvc能否解决这个问题。

我有一个Page.as 对应这个我写了一个PageMediator.as;每次new Page()时都 facade.registerMediator(new PageMediator(Page实例)); 各自去下载数据 ,收到数据下载完成消息时各自更新Page实例。可是场景上只有一个PageMediator能收到消息。

对于这种建立多个显示组件 如何运用puremvc框架开发?希望得到你的指点,谢谢!
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #3 on: October 14, 2009, 08:17:00 »

You need to give each INSTANCE of your mediator a unqiue name that corresponds to the component it holds. If you use a static NAME variable to name your instances then only one mediator can exists.

:
facade.registerMediator (new PageMediator ("My Unique Name", Page instance));

...

// inside PageMediator Constructor
public function PageMediator(name:String, viewComponent:Object) {
    super(name, viewComponent);
}


Or if your components already have a unique name on them you can use that as the name for the mediator.

:
facade.registerMediator (new PageMediator (Page instance));

...

// inside PageMediator Constructor
public function PageMediator(viewComponent:Object) {
    super(viewComponent.name+'Mediator', viewComponent);
}

« Last Edit: October 14, 2009, 08:21:06 by Jason MacDonald » Logged
youling8088
Newbie
*
Posts: 3


View Profile Email
« Reply #4 on: October 15, 2009, 03:58:30 »

Thank you very much! The problem has been resolved.
Would also like to ask a question, when I removeMediator, it will be recycled GC do? I am worried that it accounts for the memory.
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #5 on: October 15, 2009, 05:59:25 »

Just remember to clean up any event listeners using the onRemove() function and it should be GC'd.
Logged
Pages: [1]
Print