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: Question about multiple instances of a component.  (Read 7345 times)
joe
Newbie
*
Posts: 5


View Profile Email
« on: February 26, 2008, 02:11:40 »

I am using PureMVC and I have some components (with mediators/proxies) that I would like to have multiple instances of at once but i am unsure how to do this.  I have not seen any examples of doing this in PureMVC as all components in examples are concrete single instances.

EDIT: Just to clarify I want to have multiple instances of the same View component, as I understand you can have multiple different views and a single mediator.

So basically I have:

[Component A ]
[ textbox        ]
[ textbox        ]
[ datagrid       ]

and also Proxy A and Mediator A that takes Component A as the argument in the constructor.  The issue is that I need many Component A's active in the application at any one time.  Obviously following any of the examples and best use cases the view is just duplicated in every instance as they share the same mediator/proxy.

Thanks.
« Last Edit: February 26, 2008, 02:38:09 by joe » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: February 26, 2008, 03:31:47 »

Check out the HelloFlash demo.

-=Cliff>
Logged
joe
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: February 26, 2008, 07:04:12 »

Cliff,

Thanks a lot I went through the Flash demo and I understand how best to have multiple views and mediators and this technique will work well.  I do have one other quick question regarding proxies.

The majority of these shared components actually use the same data and it is just filtered differently to the view by the mediator, but some of them may need different proxies.  Do you have a best practice for this as well?  If I need multiple copies of the same view/mediator (like in the HelloFlash) but with their own model proxies?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: February 27, 2008, 06:50:55 »

There isn't a demo showing it, but multiple Proxy instances work the same.give them a unique name.

If a mediator and proxy need to be tied together, say a document editor with a proxy and mediator pair for each new document in an editor, then let the mediator know the name of its proxy, perhaps with a constructor param that it saves in a private var.

Have the proxy sen its name as the type param for notifications it sends.

Have the mediator check in its handleNotification switch/case for the notes that come from that proxy to see if the type param is equal to its proxy's name. If not, disregard the note.

-=Cliff>
Logged
Pages: [1]
Print