[Seaside] #trigger:with:

Avi Bryant avi at beta4.com
Thu Jun 10 01:30:19 CEST 2004


On Jun 9, 2004, at 7:14 AM, Sebastián Sastre wrote:

> Hi all,
>  
>     what's the reason to WAComponent implement #trigger:with: message?

Right now, it's purely an experiment.  I wanted some mechanism I could 
use to implement #onAnswer: with in a way that wasn't dependent (as it 
was initially) on dynamic scope, and so was playing around with 
introducing a general event mechanism.  I'm not at all certain that it 
will stay (and in fact in my current development branch it's gone 
again).  2.5 is still labeled alpha, and don't you forget it... ;)  
Anyway, I'm really not *sure* what it's good for, so if you find out, 
let me know.

>     Just for reference: the scenario is that some PersonEditor want's 
> to trigger that a new persona has been created and some object who has 
> previously hooked that event, adds it into the database and commit 
> changes.

So, the pattern I normally use for that is to have an Editor #answer 
the newly created object, or nil if none was created.  So the code that 
calls the editor might look like this:

(self call: PersonEditor new) ifNotNilDo:
	[:newPerson |
	self database addPerson: newPerson; commit]

But as for events, you could always use the normal MVC event mechanisms 
(#addDependent: and #changed:), or whatever the selectors for the newer 
event system are.  It's just that since web apps aren't "real time" 
it's less common to need them.

Avi


More information about the Seaside mailing list