Skip to content

Instantly share code, notes, and snippets.

@pellekrogholt
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pellekrogholt/9092401 to your computer and use it in GitHub Desktop.
Save pellekrogholt/9092401 to your computer and use it in GitHub Desktop.
|announcerInstance announcerInstanceDoInitialize point1 point2 announcer1 announcer2|
Transcript clear.
announcerInstanceDoInitialize := false.
announcerInstance := FilteringAnnouncer current.
announcerInstanceDoInitialize ifTrue: [announcerInstance initialize].
"announcerInstanceDoInitialize ifTrue: [announcerInstance teardown]."
Transcript show: 'announcerInstance subscriptions size: ', announcerInstance subscriptions size; cr.
announcer1 := announcerInstance on: [:e | e x == 1] do: [:announcement |
Transcript show: 'do something when announcement occurs'; cr.
].
announcer2 := announcerInstance on: [:e | e y == 1] do: [:announcement |
Transcript show: 'do something when announcement occurs'; cr.
].
point1 := Point new x: 1; y: 1; yourself.
announcerInstance announce: point1.
point2 := Point new x: 1; y: 2; yourself.
announcerInstance announce: point2.
"we are a bit confused with the unsubscribe ?"
announcerInstance unsubscribe: point2.
Transcript show: 'announcerInstance subscriptions size: ', announcerInstance subscriptions size; cr.
announcerInstance off: announcer1.
announcerInstance off: announcer2.
Transcript show: 'announcerInstance subscriptions size: ', announcerInstance subscriptions size; cr.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment