Skip to content

Instantly share code, notes, and snippets.

@alecmce
Created July 4, 2011 14:35
Show Gist options
  • Save alecmce/1063401 to your computer and use it in GitHub Desktop.
Save alecmce/1063401 to your computer and use it in GitHub Desktop.
PureMVC Mediator extension
private var _view:IView;
private var _notifications:Array;
final protected function registerObserver(notificationName:String, closure:Function):void
{
_view ||= View.getInstance();
_view.registerObserver(notificationName, new Observer(closure, this));
(_notifications ||= []).push(notificationName);
}
final protected function removeObservers():void
{
_view ||= View.getInstance();
for each (var notificationName:String in _notifications)
_view.removeObserver(notificationName, this);
_notifications.length = 0;
}
final protected function removeObserver(notificationName:String):void
{
_view ||= View.getInstance();
_view.removeObserver(notificationName, this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment