Dependant...

Dan Ingalls Dan at SqueakLand.org
Thu Jul 25 16:15:33 UTC 2002


>Hello,
>
>If I have :
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>AClass>>update: aParameter
>  Transcript show: 'Foo called !';cr
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
>I can do that :
>
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>o := Object new.
>o addDependent: AClass new.
>o changed: #foo
>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
>It does what I except. Good.
>
>But, how could I do if I want to give a parameter such as 'changed:with:' as Visualworks propose ?

The comprehensive solution is to duplicate the changed: method in Object, adding a parameter as follows:

changed: changeType with: parameter

	self dependents do:
		[:aDependent | aDependent update: changeType with: parameter]

and you should add a null response for update:with: in Object as well.


Another approach is to save the extra parameter in the changed object, as in

	o fooParameter: parameter.
	o changed: #foo.

and then in the view's update: method, you do something like

	changeType == #foo ifTrue:
		[parameter := model fooParameter.
		...]

	- Dan



More information about the Squeak-dev mailing list