Object subclass:#InterestConverter
instanceVariableNames:'destination selector aspect'
classVariableNames:''
poolDictionaries:''
category:'Interface-Support-Models'
!
!InterestConverter class methodsFor:'documentation'!
documentation
"
instances convert update messages into messages as setup via
#onChangeSend:to.
This is a temporary kludge and will be replaced by a more intelligent
DependencyCollection class in the future.
[author:]
Claus Gittinger
"
!
examples
"
#onChangeSend:to / #retractInterestsIn:
interested in any change:
[exBegin]
|p b|
b := [Transcript showCR:'--> notification: point has changed'].
p := Point new.
p onChangeSend:#value to:b.
Delay waitForSeconds:1.
Transcript showCR:'sending change ...'.
p changed.
p retractInterestsFor:b.
Delay waitForSeconds:1.
Transcript showCR:'sending change ...'.
p changed.
[exEnd]
#expressInterestIn:for:sendBack / #retractInterestIn:for:
interested in a specific change:
[exBegin]
|p b|
b := [Transcript showCR:'the point changed'].
p := Point new.
Transcript showCR:'interest in #foo'.
p expressInterestIn:#foo for:b sendBack:#value.
p x:1.
Transcript showCR:'now changing #bar'.
p changed:#bar.
Transcript cr.
Delay waitForSeconds:1.
Transcript showCR:'now changing #foo'.
p changed:#foo.
Transcript cr.
Delay waitForSeconds:1.
Transcript showCR:'no more interest in #foo'.
p retractInterestIn:#foo for:b.
Transcript showCR:'now changing #foo'.
p changed:#foo.
Transcript cr.
Delay waitForSeconds:1.
Transcript showCR:'interest in #bar now'.
p expressInterestIn:#bar for:b sendBack:#value.
Transcript showCR:'now changing #foo'.
p changed:#foo.
Transcript showCR:'now changing #bar'.
p changed:#bar.
Transcript cr.
Delay waitForSeconds:1.
Transcript showCR:'interest in #foo now'.
p expressInterestIn:#foo for:b sendBack:#value.
Transcript showCR:'now changing #foo'.
p changed:#foo.
Transcript showCR:'now changing #bar'.
p changed:#bar.
Transcript cr.
Delay waitForSeconds:1.
Transcript showCR:'no more interests'.
p retractInterestsFor:b.
Transcript showCR:'now changing #foo'.
p changed:#foo.
Transcript showCR:'now changing #bar'.
p changed:#bar.
Transcript cr.
[exEnd]
"
!
history
"Created: 7.3.1996 / 10:08:55 / cg"
"Modified: 8.3.1996 / 22:40:11 / cg"
! !
!InterestConverter class methodsFor:'instance creation'!
destination:anObject selector:aSelector
^ self basicNew destination:anObject selector:aSelector
!
destination:anObject selector:aSelector aspect:aspect
^ self basicNew destination:anObject selector:aSelector aspect:aspect
! !
!InterestConverter methodsFor:'accessing'!
aspect
^ aspect
"Created: 8.3.1996 / 23:00:37 / cg"
!
destination
^ destination
"Created: 7.3.1996 / 10:57:01 / cg"
!
destination:dest selector:sel
destination := dest.
selector := sel
"Created: 7.3.1996 / 10:49:13 / cg"
!
destination:dest selector:sel aspect:a
destination := dest.
selector := sel.
aspect := a
"Created: 8.3.1996 / 22:42:03 / cg"
! !
!InterestConverter methodsFor:'change & update'!
update:something with:aParameter from:someObject
(aspect isNil or:[aspect == something]) ifTrue:[
destination perform:selector
]
"Created: 7.3.1996 / 10:14:30 / cg"
"Modified: 8.3.1996 / 22:41:53 / cg"
! !
!InterestConverter class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libbasic/InterestConverter.st,v 1.5 1996-05-18 15:28:22 cg Exp $'
! !