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: How to handle multiple views of the same type?  (Read 8310 times)
tvde
Newbie
*
Posts: 2


View Profile Email
« on: October 20, 2008, 02:44:39 »

I'm struggling with the fact that I have multiple views of the same type in a tab navigator. The problem starts when calling proxy methods from the mediators attached to these views. The results of these methods are communicated through notifications. The problem is that ALL mediators get these notifications although only the mediator that called the proxy medthod is interested in the result. Is there some framework support for this or do I have to do my own plumbing?
Logged
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« Reply #1 on: October 20, 2008, 07:27:49 »

You'll have to pass around some sort of identifier (the mediators name?), so I guess that is a yes to your plumbing question.
Logged

http://joelhooks.com - my ramblings about developing with actionscript and python using pureMVC and django respectively.
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #2 on: October 20, 2008, 10:21:30 »

send the notification using the getMediatorName() as the note.setType(). Then in the response check the note.getType() against the Mediator.getMediatorName();

:
// sending note from a mediator
facade.sendNotification(ApplicationFacade.MY_NOTE, 'my body here', this.getMediatorName());

// when it comes back
case ApplicationFacade.MY_NOTE_RECIEVED:
       if(note.getType() == this.getMediatorName()) {
            // process response here
       }

[code]
[/code]
Logged
tvde
Newbie
*
Posts: 2


View Profile Email
« Reply #3 on: October 20, 2008, 12:28:19 »

Thanks for the feedback! I took the same road like Joel proposed (after making sure the mediator name is unique through createUID). I don't understand however that (Pure)MVC doesn't have support for something essential like this out of the box  ???
Logged
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« Reply #4 on: October 20, 2008, 03:16:21 »

Thanks for the feedback! I took the same road like Joel proposed (after making sure the mediator name is unique through createUID). I don't understand however that (Pure)MVC doesn't have support for something essential like this out of the box  ???

My guess is that the framework is supposed to be 'as simple as possible, but no simpler' and this sort of solution is one that will vary from project to project. Using the Notification body and/or type parameters is effective for this sort of thing, so really it does support it out of box.

If you have a good way to plumb something up, you might consider writing a utility to do so. I'd love to check it out. I'm running through solutions in my head, but I get stuck at the way I've always done it (as described in my other post).

Cheers
Logged

http://joelhooks.com - my ramblings about developing with actionscript and python using pureMVC and django respectively.
rdewolff
Newbie
*
Posts: 2


View Profile Email
« Reply #5 on: November 26, 2008, 11:02:40 »

You could load and unload mediators depending on your needs too.
Logged
Pages: [1]
Print