I would really like to have a nice chapter on announcement and variation for the next pharo by example 2. Simon started to write something and if somebody want to help you are welcome. Stef On Nov 5, 2009, at 2:57 AM, keith wrote:
On 4 Nov 2009, at 23:58, Hernán Morales Durand wrote:
Hi Keith, thanks for your reply. I've tried your implementation a bit this way:
Ok, the package is SeaWA-Core,
First of all we add a double dispatch back to the Announcement, enabling the Announcement subclass to be able to specialize announcing policy. e.g. the default is to announce to all dependents, but you might want to announce to all dependents that meet a certain criteria.
The class comment describes this as follows: ====== Unlike normal announcers which figure out what to announce to whom, as much responsibility is given to each Announcement as possible so that behaviour can be overriden completely for different scenarios.
When handling an announcement we double back and send #announceTo: to the announcement itself to give it complete control, over what it does before or after informing dependants. Its default behaviour is #dependantsAnnounce . This allows an Announcement to replace the behaviour of Announcer-#dependantsAnnounce: altogether if it wants to. ========
A second enhancement is to return the announcement from the invocation of the trigger. Though I cant remember exactly why this is now.
======= Triggering example: (we always return the original announcement)
theAnnouncement := self announcer announce: (SomeAnnouncement param: arg1). =======
Now here we come to the interesting bit.
=============== Subscriptions example:
self announcer on: SomeAnouncement do: [ :announcement | ... ]. self announcer on: SomeAnouncement send: #tellMe: to: anObject.
Normally, the announcer is passed as the argument, however, each announcement class defines #args, so it can call a method that is not expecting an Announcement as the parameter. This enables you to wire up objects that were not designed with announcements in mind.
example trigger: self announce: (HtmlUpdateAnnouncement on: html)
self announcer on: HtmlUpdateAnouncement send: #renderOn: to: anObject.
where:
HtmlUpdateAnnouncement-#args ^ Array with: html
=================
does that help?
Keith
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project