Skip to content

Commit

Permalink
Added convenience methods about subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Oct 19, 2024
1 parent 2487e31 commit aa4f52a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
20 changes: 18 additions & 2 deletions repository/OpenPonk-Model/OPAnnouncableObject.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ OPAnnouncableObject >> silentlyDo: aBlock [
announcer := oldAnnouncer
]

{ #category : 'announcement registration' }
OPAnnouncableObject >> unsubscribe: anObject [

^ self announcer unsubscribe: anObject
]

{ #category : 'announcement registration' }
OPAnnouncableObject >> when: anAnnouncementClass do: aValuable [

Expand Down Expand Up @@ -106,12 +112,22 @@ OPAnnouncableObject >> when: anEvent do: aBlock for: aReceiver [
]

{ #category : 'announcement registration' }
OPAnnouncableObject >> when: anAnnouncementClass send: aSelector to: anObject [
self announcer when: anAnnouncementClass send: aSelector to: anObject
OPAnnouncableObject >> when: anAnnouncementClass send: aSelector to: aReceiver [

^ self announcer
when: anAnnouncementClass
send: aSelector
to: aReceiver
]

{ #category : 'announcement registration' }
OPAnnouncableObject >> whenChanged: aBlock [

self when: OPElementChanged do: aBlock for: aBlock receiver
]

{ #category : 'announcement registration' }
OPAnnouncableObject >> whenChangedSend: aSelector to: aReceiver [

^ self when: OPElementChanged send: aSelector to: aReceiver
]
6 changes: 3 additions & 3 deletions repository/OpenPonk-Model/OPModelObject.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ OPModelObject >> remove [

{ #category : 'removing' }
OPModelObject >> remove: anElement [
(elements includes: anElement)
ifFalse: [ ^ anElement ].
anElement announcer unsubscribe: self.

(elements includes: anElement) ifFalse: [ ^ anElement ].
anElement unsubscribe: self.
anElement removeFrom: self.
elements remove: anElement.
self announceRemoved: anElement.
Expand Down

0 comments on commit aa4f52a

Please sign in to comment.