diff --git a/repository/OpenPonk-Model/OPAnnouncableObject.class.st b/repository/OpenPonk-Model/OPAnnouncableObject.class.st index c90dd56..2086dab 100644 --- a/repository/OpenPonk-Model/OPAnnouncableObject.class.st +++ b/repository/OpenPonk-Model/OPAnnouncableObject.class.st @@ -44,13 +44,8 @@ OPAnnouncableObject >> announceRemoved: anElement [ { #category : 'accessing' } OPAnnouncableObject >> announcer [ - announcer ifNil: [ self announcer: Announcer new ]. - ^ announcer -] -{ #category : 'accessing' } -OPAnnouncableObject >> announcer: anAnnouncer [ - announcer := anAnnouncer + ^ announcer ifNil: [ announcer := Announcer new ] ] { #category : 'announcing' } @@ -78,6 +73,21 @@ OPAnnouncableObject >> unsubscribe: anObject [ ^ self announcer unsubscribe: anObject ] +{ #category : 'announcement registration' } +OPAnnouncableObject >> weakWhen: anAnnouncementClass send: aSelector to: aReceiver [ + + ^ self announcer weak + when: anAnnouncementClass + send: aSelector + to: aReceiver +] + +{ #category : 'announcement registration' } +OPAnnouncableObject >> weakWhenChangedSend: aSelector to: aReceiver [ + + ^ self weakWhen: OPElementChanged send: aSelector to: aReceiver +] + { #category : 'announcement registration' } OPAnnouncableObject >> when: anAnnouncementClass do: aValuable [ diff --git a/repository/OpenPonk-Model/OPModelObject.class.st b/repository/OpenPonk-Model/OPModelObject.class.st index c85105e..119597d 100644 --- a/repository/OpenPonk-Model/OPModelObject.class.st +++ b/repository/OpenPonk-Model/OPModelObject.class.st @@ -28,7 +28,7 @@ OPModelObject >> add: anElement [ (elements includes: anElement) ifTrue: [ ^ anElement ]. anElement addedTo: self. elements add: anElement. - anElement when: OPElementChanged send: #changed to: self. + anElement weakWhen: OPElementChanged send: #changed to: self. self announceAdded: anElement. ^ anElement ] @@ -140,7 +140,6 @@ OPModelObject >> remove [ OPModelObject >> remove: anElement [ (elements includes: anElement) ifFalse: [ ^ anElement ]. - anElement unsubscribe: self. anElement removeFrom: self. elements remove: anElement. self announceRemoved: anElement.