[Q]: Update: mechanism

Rob Withers rwithers12 at attbi.com
Mon Dec 9 14:05:40 UTC 2002


Thierry and Ned,

The form #triggerEvent:withArguments:ifNotHandled: is a specialization for
the publisher not the subscriber.   The ifNotHandled part is executed if
there are no actions registered for that particular event.  It is not used
if an error occurs when evaluating a registered action.

Thierry, we probably do not want to install exception handlers in these
methods, since that can slow things down (a little).  Basically your
subscriber is violating the contract, by asking for a msg to be sent but not
understanding it.  One thing you could do while developing is to use the
following form:

publisher
    when: myEvent
    evaluate: [:arg | (self respondsTo: #eventHandler:)
        ifTrue: [self perform: #eventHandler: with: arg] ].

Please remember to send #releaseActionMap to the publisher when done, or at
least #removeActionsWithReceiver:  if your subscriber needs to disappear
before your publisher.  For the above case, the receiver is a block, so even
that wont work.  You will need to send #removeActionsForEvent:, which may
damage other subscribers....YKMV

You must explicitly manage deregistration until we can get WeakMessageSend
into the image (3.5...), then the subscribers will be held weakly.

rob

----- Original Message -----
From: <thierry_Reignier at hotmail.com>
To: <squeak-dev at lists.squeakfoundation.org>
Sent: Monday, December 09, 2002 3:02 AM
Subject: Re: [Q]: Update: mechanism


> Hi,
>
> >> But with the new mechanism my model MUST implement aSelector.
> > Easier... there are triggerEvent...ifNotHandled: [ ] variants so that
> > you don't have to check first.
>
> I have tried it and still got an abend. I am suggesting this
> implementation:
>
> Object>>triggerEvent: anEventSelector
> withArguments: anArgumentList
> ifNotHandled: anExceptionBlock
>
>     ^[(self
> actionForEvent: anEventSelector
> ifAbsent: [^anExceptionBlock value])
>        valueWithArguments: anArgumentList]
> on: Error
> do: [:ex | anExceptionBlock value]
>
> If my morph register the event but my model does not implement
> it I still got the abend. I have to catch the doesNotUnderstand.
>
> It is correct?
>
> Thierry
>
>




More information about the Squeak-dev mailing list