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 [2]
Print
Author Topic: Notification Chaining Utility  (Read 36434 times)
binarycrafts
Newbie
*
Posts: 6



View Profile WWW Email
« Reply #15 on: July 21, 2008, 01:38:32 »

is only called when a Mediator is registered and will therefore only be useful if you remove the Mediator and then reregister it
Yes, that makes perfect sense. But the catch is that it gets called only at register time.
The problem with the ChainNotifier is that it assumes that listNotificationInterests is called after it's every nextAction call. That does not happen. The bug kicks in wen you have over 2 nodes added. Works for just 2 nodes.
So it needed some tweaks to work fine.
Logged
Neil Manuell
Courseware Beta
Sr. Member
***
Posts: 109


View Profile Email
« Reply #16 on: October 05, 2008, 08:33:41 »

hi trilec, have seen that you've done some stuff on chaining commands

I've been working on a prototype that will encapsulate all command chains into a central data source
and will also allow non-linear chaining of commands. 

Just thought i'd say hi, and make you aware of it (I don't want to work on a problem that someone else has fixed), been blogging about it a bit here http://revisual.co.uk/?p=172 , and I'd be interested in your comments as to whether its a good idea, usefull etc.

cheers
Logged
Neil Manuell
Courseware Beta
Sr. Member
***
Posts: 109


View Profile Email
« Reply #17 on: October 11, 2008, 12:38:43 »

hey, trilec
been trying out your chaining util.. nice and simple and very useful, thanks
Logged
Neil Manuell
Courseware Beta
Sr. Member
***
Posts: 109


View Profile Email
« Reply #18 on: October 14, 2008, 03:13:08 »

here is a fix for the listNotificationInterests

 override public function listNotificationInterests():Array
      {
         if(listenersArray.length == 0 ) return []; //nothing to do
         var chainName:String = null;
         if(paused == false) chainName = listenersArray[current];
         var actionsAndListerners:Array = actionArray.concat(listenersArray);
         return actionsAndListerners;
      }

NB the change is here: var actionsAndListerners:Array = actionArray.concat(listenersArray);

I don't know how it effects the actions... I haven't looked at them.

also a feature request:

instead of this:
chainNotifier.addNode(NotificationNames.INITIATE_ACTORS, NotificationNames.ACTOR_INITIATION_COMPLETE );

can we have this:
chainNotifier.addNode(NotificationNames.INITIATE_ACTORS, InitActorsCommand,  NotificationNames.ACTOR_INITIATION_COMPLETE );

the ChainNotifier registers the Commands with the facade (and removes them afterward?), which means that all the information is available in the one place.

cheers :)
Logged
Neil Manuell
Courseware Beta
Sr. Member
***
Posts: 109


View Profile Email
« Reply #19 on: October 15, 2008, 05:03:36 »

I noticed that the body and types weren't getting passed to the next command in the chain, again, this might be dealt with in the actions, but I thought I'ld post my fix here

public function nextAction(node:ChainNotifierNode=null):void
{   
   if(current >= listenersArray.length-1) return;
   current++;
   doSendNotification(current, node);
}
added a second, optional param to soSendNotification, the lastNode:

public function doSendNotification(index:int=0, lastNode:ChainNotifierNode=null):void    
{   
   if(listenersArray.length == 0 || listenersArray.length < current) return;
   var node:ChainNotifierNode;
   var name:String = listenersArray[index]; //get node name
   node = chainAssocArray[ name ] as ChainNotifierNode; //get node
   if(lastNode == null){
      sendNotification( node.notifySender, node.notifyBody, node.notifyType );
   }else{
      sendNotification( node.notifySender, lastNode.notifyBody, lastNode.notifyType );
   }
         
}
I don't know how this will affect adding body and type in the addNode method, as I'm not doing that, just passing a body along the chain

cheers
Logged
Pages: 1 [2]
Print