On 07.01.2010 14:50, Schwab,Wilhelm K wrote:
Gary,
If announcements are at all what I am expecting (perhaps a non-trivial assumption??), then I doubt it will be a problem. One would observe the world/window-manager for open events, and then express interest in events from individual windows. That might turn out to be easier on consumers than getting everything from one source. Cleanup should be trivial if the announcement framework uses weak references.
Bill
The Pharo implementation does not include weak announcement subscriptions, you have to manually unsubscribe if you need to. This can be solved in VisualWorks without keeping a list of whom you are subscribed to, by using the fact that the block in subscribe:do: can take 2 args instead of one, in which case the second argument is the announcer. If this were the case in the Pharo/Squeak implementation, the Global WindowOpened/Local InterestingWindowEvents could be written: (receiveAnnouncements to true in initialize, false in release) SystemWindow openAnnouncer subscribe: WindowOpened do: [:ann : | ann window satisfiesMyCriteria ifTrue: [ ann window subscribe: InterestingWindowEvent do: [:ann :announcer | receiveAnnouncements ifTrue: [self handleInterestingEvent: ann] ifFalse: [announcer unsubscribe: self]] Not very pretty, but still better than the alternative if you know the dynamic announcer is likely to outlive the consumer. Cheers, Henry