PHP Code:
/***
*** Notification Centre (libnotice ) ***
+(void) addObsrver( object, recall, event );
+(void) remObserver( object );
-(void) postNotification( event, {params} );
***/
public function addObserver( object, recallEvent, event )
{
for ( temp.notice: this.notifications )
{
if ( temp.notice[0] != object )
continue;
if ( temp.notice[1] != recallEvent )
continue;
if ( temp.notice[2] != event )
continue;
return;
}
this.notifications.add( {object, recallEvent, event } );
return;
}
public function remObserver( object )
{
for ( i = 0; i < this.notifications.size(); i ++ )
{
if ( this.notifications[i][0] == object
|| this.notifications[i][0] == null ) // Shouldn't be here!
{
this.notifications.delete( i );
i --;
continue;
}
}
return;
}
function postNotification( event, param )
{
temp.eventParams = { this };
temp.eventParams.addarray( param );
for ( temp.notice: this.notifications )
{
if ( temp.notice[2] != event )
continue;
( temp.notice[0] ).trigger(
temp.notice[1],
temp.eventParams );
}
return;
}