Back when Vassili first started talking about Announcements, I really didn't see the point - I had just switched BottomFeeder over from change/update to Trigger Events, and those seemed sufficient. Now that I've been working with Widgetry (Swallow), I see what the advantage is. Consider a trigger event that notifies you of a keyboard event:
Subscribing:
someObject when: #keyboardEvent send: keyboardEvent: to: self
This depends on the triggering object sending an argument along:
kbdHandler triggerEvent: #keyboardEvent with: keyboardEventObject
Which is fine, except for one thing - the object being sent is sent more or less simply by convention, and the triggering object has to send it along. Now consider the way an Announcement works:
Subscribing:
(self paneAt: #input) inputField
when: KeystrokeAboutToBeProcessed
send: #possibleCREvent:
to: self.
What do I expect to see as the argument? An instance of the KeystrokeAboutToBeProcessed class - so instead of pushing symbols around, we push full objects around. This particular one is sent like this:
targetPane
announce: (KeystrokeAboutToBeProcessed keyboardEvent: aKeyboardEvent)
The nice thing is, we've moved "up" a level from symbols to objects. None of that was clear to me back when I read about it - it's like an "aha moment" all over again.
Technorati Tags:
smalltalk