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: Notification, "type" property ?  (Read 16956 times)
nisimjoseph
Full Member
***
Posts: 22


View Profile Email
« on: March 03, 2009, 02:10:56 »

why do we need the "type" property in the Notification object ?
i need some examples for see the use of it ?

10x,
Nisim
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: March 04, 2009, 05:46:10 »

You can use it as a discriminator when multiple mediators are signed up for the same notification but only one should act upon it.

For instance: you have a document editing program and may have multiple documents open at once. You have an instance of a DocProxy to hold each document and an instance of DocViewMediator handling the DocView instance that is displaying any given doc.

When the document is loaded, saved, closed or updated, the associated DocProxy sends a notification that its associated DocViewMediator should act upon.

Since there are multiple instances of DocpProxy registered with the Model and Multiple DocMediators registered with the View, they must each have unique Proxy and Mediator names. The easist way to pair the proxy and mediator is to register them both under the same thing such as the document name.

So when any instance of DocProxy sends a notification that should be picked up by its DocViewMediator mate, it simply sends 'this.getProxyName()' as the type parameter of the sendNotification call.

In the DocViewMediator's handleNotification method, for notifications coming from the DocProxy, the mediator should only take action if 'this.getMediatorName() == notification.getType()'

Hope this helps,
-=Cliff>
Logged
nisimjoseph
Full Member
***
Posts: 22


View Profile Email
« Reply #2 on: March 04, 2009, 01:53:34 »

thank you for the answer.
i stuck in the middle of your answer. i need clarification before continue.
you said that every document have his own DocProxy, but you can create only one Proxy that handle the specific data for it.
in the Model code you have have only 1 Proxy for that proxy name. how can you create multi proxies from the same type?

10x,
Nisim
Logged
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« Reply #3 on: March 04, 2009, 09:46:24 »

thank you for the answer.
i stuck in the middle of your answer. i need clarification before continue.
you said that every document have his own DocProxy, but you can create only one Proxy that handle the specific data for it.
in the Model code you have have only 1 Proxy for that proxy name. how can you create multi proxies from the same type?

10x,
Nisim

:
public class MyProxy extends Proxy implements IProxy
{
        public static const NAME:String = "MyProxyName::";
        private var instanceUID:String;

        public function MyProxy(instanceUID:String)
        {
                this.instanceUID = instanceUID;
                super(this.getProxyName(), new myVO())
        }

        override public function getProxyName():String
        {
                return NAME+this.instanceUID;
        }               
}

http://forums.puremvc.org/index.php?topic=596.0

Here is some discussion on the subject.
Logged

http://joelhooks.com - my ramblings about developing with actionscript and python using pureMVC and django respectively.
nisimjoseph
Full Member
***
Posts: 22


View Profile Email
« Reply #4 on: March 05, 2009, 01:30:21 »

ok, got it!
10x on the help.

Nisim
Logged
Pages: [1]
Print