Recent Changes - Search:

OtherPlaces

PmWiki

pmwiki.org

edit SideBar

AnnouncementTemplate

The main code develops around announcements, but you might have difficulty isolating that aspect. Here is a simplified template for using announcements. It has two announcements (Ann1, Ann2), there is an Announcer (MyAnnouncer1) and a Subscriber (MySubscriber1). The Code in MyRun1 is just glue. Type 'test := MyRun1 new run' in a workspace. Open a transcript to see the DoIt output.

You can download the code here, http://dougedmunds.com/pub/Pharo. Get Sandbox110430-001.zip.

Object subclass: #MySubscriber1
  instanceVariableNames: ''
  classVariableNames: ''
  poolDictionaries: ''
  category: 'Sandbox110430'!

!MySubscriber1 methodsFor: 'as yet unclassified' stamp: 'DougEdmunds 4/30/2011 14:32'!
getMissionCriticalMessage
  Transcript cr; show: '***FIRE!! EVERYONE OUT***'.
  "after which you do other stuff"! !

!MySubscriber1 methodsFor: 'as yet unclassified' stamp: 'DougEdmunds 4/30/2011 14:59'!
getMissionCriticalMessage2
  Transcript cr; show: '**FALSE ALARM ***'.
  "after which you do other stuff"! !

!MySubscriber1 methodsFor: 'as yet unclassified' stamp: 'DougEdmunds 4/30/2011 14:32'!
subscribeAnn1: x
  Transcript cr; show: 'subscribing'.
  x subscribe: Ann1 send: #getMissionCriticalMessage to: self
  "after which you do other stuff"! !

!MySubscriber1 methodsFor: 'as yet unclassified' stamp: 'DougEdmunds 4/30/2011 14:59'!
subscribeAnn2: x
  Transcript cr; show: 'subscribing two'.
  x subscribe: Ann1 send: #getMissionCriticalMessage2 to: self
  "after which you do other stuff"! !


Object subclass: #Ann1
  instanceVariableNames: ''
  classVariableNames: ''
  poolDictionaries: ''
  category: 'Sandbox110430'!


Announcer subclass: #MyAnnouncer1
  instanceVariableNames: ''
  classVariableNames: ''
  poolDictionaries: ''
  category: 'Sandbox110430'!

!MyAnnouncer1 methodsFor: 'as yet unclassified' stamp: 'DougEdmunds 4/30/2011 14:30'!
announce1
  Transcript cr; show: 'before announcing1'.
  self announce: Ann1.  
  Transcript cr; show: 'after announcing1'.
! !

!MyAnnouncer1 methodsFor: 'as yet unclassified' stamp: 'DougEdmunds 4/30/2011 15:01'!
announce2
  Transcript cr; show: 'before announcing2'.
  self announce: Ann2.  
  Transcript cr; show: 'after announcing2'.
! !


Object subclass: #MyRun1
  instanceVariableNames: 'x'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'Sandbox110430'!

!MyRun1 methodsFor: 'as yet unclassified' stamp: 'DougEdmunds 4/30/2011 15:01'!
run
  |   y x |

  Transcript clear.
  Transcript cr; show: 'new run at ', Time now asString.
  x := nil.
  x := MyAnnouncer1 new.
  y := nil.
  y := MySubscriber1 new.
  "First subscribe"
  y subscribeAnn1: x.
  y subscribeAnn2: x.
  x announce1.
  x announce2.! !


Announcement subclass: #Ann2
  instanceVariableNames: ''
  classVariableNames: ''
  poolDictionaries: ''
  category: 'Sandbox110430'!


Edit - History - Print - Recent Changes - Search
Page last modified on May 01, 2011, at 12:19 PM