links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Publish-Subscribe - Event Dispatching and Triggering
Last updated at 4:39 pm UTC on 12 April 2000
PostOffice is an event dispatching system. It allows you to use constructs like -

when: #thisEvent send: #aSelector to: aSubscriber.

Most of the protocol needed is in Object, under 'publish-subscribe'. PostOffice does the actual message dispatching, and there are some examples on the class side. PostOffice is implemented as a Singleton. PostOffice uses weak references to handle all publishers of, and subscribers to, events. No explicit removal is required. There are two change sets. One sets up Publish-Subscribe in tandem with Squeaks normal 'changed/update' dependency protocol. The other, which should only be filed in AFTER Publish-Subscribe, allows PostOffice to take care of all events. It transparently implements all of the changed/update protocol. Exception support is a prerequisite, and must be filed prior to the publish-subscribe change sets.

Missing File (/squeak/uploads/%21exceptionHandling1g2.st%21) File in first.

The two change sets are:

1. Missing File (/squeak/uploads/%21PublishSubscribe.cs%21)

2. Missing File (/squeak/uploads/%21Dependents.cs%21)
[It appears that these change sets are no longer on the server. What a shame - I'd love to use them - cbc]

Note: This version updated 12 July 1999. Improvements include:

fixing a problem with the garbage collector
a first cut at implementing #when: anEvent do: aBlock
use of exceptions to force semaphores to behave after abnormal termination of the critical block.

PostOffice should be transparent to the user. That is, dependencies with events can be set up as in the test examples, using the methods in Object. In essence, the entire class is private. The only class side method of importance is default - all other methods are for testing and are discardable.