What about using the methods: #triggerEvent:with: and #when:send:to: obj when: #price send: #updatePrice: to: anObject2
obj triggerEvent: #price with: oldPrice where Object2>>updatePrice: aPrice Hilaire Chris Kassopulo a écrit : > Greetings, > > The basic dependency example from "Smalltalk By Example" uses > Visualworks changed:with and update:with:from: methods like this: > > price: aPrice > | oldPrice | > oldPrice := self price. > price := aPrice. > self changed: #price with: oldPrice > > update: aSymbol with: oldPrice from: aStock > (aSymbol == #price) ifTrue: > [Transcript > cr; show: thisContext; tab; show: aSymbol; tab; > nextPutAll: 'Price changed from: '; show: oldPrice; tab; > nextPutAll: 'To: '; show: aStock price; flush] > > The problem is that Squeak only implements update:with: so the > aStock price messaging doesn't work. My solution was to follow > VW's implementation by making the following changes: > > Modified the changed:with: method to include from:. > > changed: anAspect with: anObject > self dependents do: [:aDependent | aDependent update: anAspect with: > anObject from: self] > > Added an update:with:from: method. > > update: anAspect with: anObject from: aSender > ^ self update: anAspect with: anObject > > It took a while to see the problem and without looking at VW, > I never would have been able to figure a way. Is my fix > reasonable? > > VW also implements expressInterestIn:for:sendBack: and > onChangeSend:to: methods. Anyone familiar with them and care to > provide pointers on the possibility of implementing something > similar in Squeak? > > Thanks, > Chris > > > _______________________________________________ > Beginners mailing list > [email protected] > http://lists.squeakfoundation.org/mailman/listinfo/beginners > _______________________________________________ Beginners mailing list [email protected] http://lists.squeakfoundation.org/mailman/listinfo/beginners
