13.8 Observer Interface

ORIGIN '~beta/basiclib/betaenv';
INCLUDE '~beta/containers/sets';
-- lib: Attributes --
Subject:
  (#
     observerType:< Observer;
     init:< (#  do observers.init; INNER ;  #);
     attach:
       (# theObserver: ^observerType; 
       enter theObserver[]
       do theObserver[]->observers.insert; 
       #);
     detach:
       (# theObserver: ^observerType; 
       enter theObserver[]
       do theObserver[]->observers.delete
       #);
     Notify:
       (# current: ^observerType; 
       do
          observers.scan
            (# 
            do
               (if not current.ignore then
                   current[]->THIS(notify).current[]; INNER notify; 
               if);
               
            #);
          
       #);
     notifyUpdate: notify (#  do current.Update;  #);
     notifyOfType:
       (# type:< Observer; current: ^type; 
       do
          observers.scan
            (# 
            do
               (if not current.ignore then
                   (if current## <= type## then
                       current[]->THIS(notifyOfType).current[];
                       INNER notifyOfType;
                       
                   if);
                   
               if);
               
            #);
          
       #);
     observers: @set (# element:: observerType #);
     
  #);
Observer: (# ignore:< booleanValue; update:< (# do INNER #);  #)


13.8 Observer Interface
© 1991-2004 Mjølner Informatics
[Modified: Wednesday July 9th 2003 at 15:32]