Sha256: 41a457ade97113ef7860801c7992be3109f70854dac8be41e1f0594aee0ad998

Contents?: true

Size: 1.16 KB

Versions: 10

Compression:

Stored size: 1.16 KB

Contents

Smalltalk current createPackage: 'Kernel-Announcements' properties: #{}!
Object subclass: #AnnouncementSubscription
	instanceVariableNames: 'block announcementClass'
	category: 'Kernel-Announcements'!

!AnnouncementSubscription methodsFor: 'accessing'!

announcementClass
	^announcementClass
!

announcementClass: aClass
	announcementClass := aClass
!

block
	^block
!

block: aBlock
	block := aBlock
! !

!AnnouncementSubscription methodsFor: 'announcing'!

deliver: anAnnouncement
	(self handlesAnnouncement: anAnnouncement)
		ifTrue: [self block value: anAnnouncement]
!

handlesAnnouncement: anAnnouncement
	^anAnnouncement isKindOf: self announcementClass
! !

Object subclass: #Announcer
	instanceVariableNames: 'registry subscriptions'
	category: 'Kernel-Announcements'!

!Announcer methodsFor: 'announcing'!

announce: anAnnouncement
	subscriptions do: [:each |
		each deliver: anAnnouncement]
! !

!Announcer methodsFor: 'initialization'!

initialize
	super initialize.
	subscriptions := Array new
! !

!Announcer methodsFor: 'subscribing'!

on: aClass do: aBlock
	subscriptions add: (AnnouncementSubscription new
		block: aBlock;
		announcementClass: aClass;
		yourself)
! !

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
resin-0.2.1 amber/st/Kernel-Announcements.st
resin-0.2.0 amber/st/Kernel-Announcements.st
resin-0.1.0 amber/st/Kernel-Announcements.st
resin-0.0.8 amber/st/Kernel-Announcements.st
resin-0.0.7 amber/st/Kernel-Announcements.st
resin-0.0.6 amber/st/Kernel-Announcements.st
resin-0.0.5 amber/st/Kernel-Announcements.st
resin-0.0.4 amber/st/Kernel-Announcements.st
resin-0.0.3 amber/st/Kernel-Announcements.st
resin-0.0.2 amber/st/Kernel-Announcements.st