Discussion:
Proper use of events
Steven W. Riggins
2005-12-26 20:40:01 UTC
Permalink
I'm struggling with when to use tweak scripts and events.

I have a class system where I have channels, which hold on to
events. When the timeline starts, it puts the events on a
scheduler. When the scheduler starts an event, it sends startEvent
to the event.

Now the event can do what it needs to, show, start media etc. It
also does a self signal: eventStarted.

the channel has started a script to listen for these:

self startScript: #eventStarted:
withArguments:{anEvent}
when:{anEvent. #eventStarted}.


Now if I run the following code one line at a time in a tweak
workspace, the result is 1 (correct) when I run it under one doit,
the result is 0. I am sure this is due to asynchronous events.

The question is: How do I know when events get sent? is this a good
use of events?

When I wrote an SUnit to test this, it failed of course, as the event
had not been triggered yet.

Thanks for the insight!

Steve
Steven Riggins
2005-12-26 20:44:46 UTC
Permalink
As a followup, I changed startScript to the synchronous runScript and
it now works. Questions still are valid: when and how should scripts
be used, opposed to sending messages directly to objects.
Post by Steven W. Riggins
I'm struggling with when to use tweak scripts and events.
I have a class system where I have channels, which hold on to
events. When the timeline starts, it puts the events on a
scheduler. When the scheduler starts an event, it sends startEvent
to the event.
Now the event can do what it needs to, show, start media etc. It
also does a self signal: eventStarted.
withArguments:{anEvent}
when:{anEvent. #eventStarted}.
Now if I run the following code one line at a time in a tweak
workspace, the result is 1 (correct) when I run it under one doit,
the result is 0. I am sure this is due to asynchronous events.
The question is: How do I know when events get sent? is this a
good use of events?
When I wrote an SUnit to test this, it failed of course, as the
event had not been triggered yet.
Thanks for the insight!
Steve
_______________________________________________
Tweak mailing list
http://impara.de/mailman/listinfo/tweak
Loading...