puremvc
|
|
« Reply #1 on: May 17, 2009, 08:33:11 » |
|
It is mostly for clarity, yes. The observers variable in this method is merely a reference to the the array that may or may not exist in observerMap[ notificationName ], it isn't a copy of that array. It is defined so that we may easily evaluate whether the new observer needs be pushed onto the existing array, or have one created if this is the first observer for the notification.
It could be written as below, but that would be less clear and I doubt any more efficient:
public function registerObserver ( notificationName:String, observer:IObserver ) : void { if( observerMap[ notificationName ] ) { Array(observerMap[ notificationName ]).push( observer ); } else { observerMap[ notificationName ] = [ observer ]; } } -=Cliff>
|