906 |
906 |
907 !Object methodsFor:'dependents-interests'! |
907 !Object methodsFor:'dependents-interests'! |
908 |
908 |
909 onChangeSend:aSelector to:anObject |
909 onChangeSend:aSelector to:anObject |
910 "arrange for aSelector to be sent to anObject whenever the receiver |
910 "arrange for aSelector to be sent to anObject whenever the receiver |
911 changes." |
911 changes. |
|
912 Use retractInterestsFor: in case you are no longer interested" |
912 |
913 |
913 "/ for now, use an interestConverter, which is somewhat less efficient. |
914 "/ for now, use an interestConverter, which is somewhat less efficient. |
914 "/ In the future, a more intelligent DependencyCollection class is planned for |
915 "/ In the future, a more intelligent DependencyCollection class is planned for |
915 |
916 |
916 ((self interests ? #()) |
917 ((self interests ? #()) |
917 contains:[:anInterest | |
918 contains:[:anInterest | |
918 (anInterest isInterestConverter) |
919 (anInterest isInterestConverter) |
919 and:[ anInterest destination == anObject |
920 and:[ anInterest destination == anObject |
920 and:[ anInterest selector == aSelector]] |
921 and:[ anInterest selector == aSelector]] |
921 ]) |
922 ]) |
922 ifTrue:[^ self]. |
923 ifTrue:[^ self]. |
923 |
924 |
924 self addInterest:(InterestConverter |
925 self addInterest:(InterestConverter |
925 destination:anObject |
926 destination:anObject |
926 selector:aSelector) |
927 selector:aSelector) |
927 |
928 |
928 " |
929 " |
929 |p b| |
930 |p b| |
930 |
931 |
931 b := [Transcript showCR:'the point changed']. |
932 b := [Transcript showCR:'the point changed']. |