topleft topright
  PureMVC Forums

Welcome, Guest. Please login or register.
September 02, 2010, 07:48:47 AM
Home Help Search Login Register
News: ATTENTION: Spambots must die! Humans must visit http://contact.futurescale.com to request forum access.

Pages: [1]
Print
Author Topic: Notification, "type" property ?  (Read 1876 times)
nisimjoseph
Full Member
***
Posts: 22


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

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: 2366



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

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
« Reply #2 on: March 04, 2009, 01:53:34 PM »

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
« Reply #3 on: March 04, 2009, 09:46:24 PM »

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

Code:
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
« Reply #4 on: March 05, 2009, 01:30:21 AM »

ok, got it!
10x on the help.

Nisim
Logged
Pages: [1]
Print
Jump to:  



Login with username, password and session length

Powered by SMF 1.1.11 | SMF © 2006-2007, Simple Machines LLC
Copyright © 2006-2008 Futurescale, Inc.