Setting Up for Events in Other than Model Classes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting Up for Events in Other than Model Classes

Eric Taylor
Hello Forum!

This afternoon, I set up for events in ActiveTreeModel and
ActiveTreeCursor, where the former is a publisher and the latter is a
subscriber.  I can't seem to get the scheme to work, however.  This is
what I've done:

1) In a particular method in ActiveTreeModel, I trigger an
#invalidateCursorsInParent: event.  The event has one argument, the
parentObject;
2) In ActiveTreeCursor, a direct subclass of Object, I have a method
called #initializeOn:over:, wherein I subscribe to the
#invalidateCursorsInParent: event, like this:

self when: #invalidateCursorsInParent: send:
#onInvalidatedCursorsInParent: to: self

3) ActiveTreeCursor also has a method called
#onInvalidatedCursorsInParent:

I've looked at ListModel, another class outside the Model hierarchy that
triggers events, and it would seem that I need an <events> variable and
four overriding event-oriented methods.  When I add them, following the
same pattern, I still have no success.  I've also made sure that all of
my colons are accounted for in method selectors and symbols, and I can't
find any problem there either.

ActiveTreeCursor is an observer in this case.  What am I missing here?

Thanks.


Cheers,

Eric


Reply | Threaded
Open this post in threaded view
|

Re: Setting Up for Events in Other than Model Classes

Eric Taylor
I answered my own question:

In ActiveTreeCursor, I was hanging off "self" instead of "self
contents", where #contents is equivalent to #model in this context.

Cheers,

Eric

> -----Original Message-----
> From: Eric Taylor [mailto:[hidden email]]
> Posted At: Saturday, July 01, 2006 7:57 PM
> Posted To: comp.lang.smalltalk.dolphin
> Conversation: Setting Up for Events in Other than Model Classes
> Subject: Setting Up for Events in Other than Model Classes
>
> Hello Forum!
>
> This afternoon, I set up for events in ActiveTreeModel and
> ActiveTreeCursor, where the former is a publisher and the latter is a
> subscriber.  I can't seem to get the scheme to work, however.  This is
> what I've done:
>
> 1) In a particular method in ActiveTreeModel, I trigger an
> #invalidateCursorsInParent: event.  The event has one argument, the
> parentObject;
> 2) In ActiveTreeCursor, a direct subclass of Object, I have a method
> called #initializeOn:over:, wherein I subscribe to the
> #invalidateCursorsInParent: event, like this:
>
> self when: #invalidateCursorsInParent: send:
> #onInvalidatedCursorsInParent: to: self
>
> 3) ActiveTreeCursor also has a method called
> #onInvalidatedCursorsInParent:
>
> I've looked at ListModel, another class outside the Model hierarchy
that
> triggers events, and it would seem that I need an <events> variable
and
> four overriding event-oriented methods.  When I add them, following
the
> same pattern, I still have no success.  I've also made sure that all
of
> my colons are accounted for in method selectors and symbols, and I
can't

> find any problem there either.
>
> ActiveTreeCursor is an observer in this case.  What am I missing here?
>
> Thanks.
>
>
> Cheers,
>
> Eric


Reply | Threaded
Open this post in threaded view
|

Re: Setting Up for Events in Other than Model Classes

Esteban A. Maringolo
In reply to this post by Eric Taylor
Hello Eric,

Eric Taylor escribió:

> I've looked at ListModel, another class outside the Model hierarchy that
> triggers events, and it would seem that I need an <events> variable and
> four overriding event-oriented methods.  When I add them, following the
> same pattern, I still have no success.  I've also made sure that all of
> my colons are accounted for in method selectors and symbols, and I can't
> find any problem there either.

Just as a side note, any object can be observed (be a model), and there
is no need to define an inst var named 'events', the difference between
the default implementation and the Model (also ListModel, Package, and
some others), is that they use a particular instvar to save message
sends (and improve performance) in the lookup of their events
collection, while Object's default implementation is a registry of
events collection for all the objects.

See the implementors of #setEvents: and the class comment of Model for
further information.

Hope this helps,

Regards.

--
Esteban.


Reply | Threaded
Open this post in threaded view
|

Re: Setting Up for Events in Other than Model Classes

Eric Taylor
Esteban,

I see.  Since I'm dealing with the update of cursors, which should be as
efficient as possible, I will look further into the few classes you
suggested.

Thanks very much.

Cheers,

Eric

> -----Original Message-----
> From: Esteban A. Maringolo [mailto:[hidden email]]
> Posted At: Saturday, July 01, 2006 9:36 PM
> Posted To: comp.lang.smalltalk.dolphin
> Conversation: Setting Up for Events in Other than Model Classes
> Subject: Re: Setting Up for Events in Other than Model Classes
>
> Hello Eric,
>
> Eric Taylor escribió:
>
> > I've looked at ListModel, another class outside the Model hierarchy
that
> > triggers events, and it would seem that I need an <events> variable
and
> > four overriding event-oriented methods.  When I add them, following
the
> > same pattern, I still have no success.  I've also made sure that all
of
> > my colons are accounted for in method selectors and symbols, and I
can't
> > find any problem there either.
>
> Just as a side note, any object can be observed (be a model), and
there
> is no need to define an inst var named 'events', the difference
between

> the default implementation and the Model (also ListModel, Package, and
> some others), is that they use a particular instvar to save message
> sends (and improve performance) in the lookup of their events
> collection, while Object's default implementation is a registry of
> events collection for all the objects.
>
> See the implementors of #setEvents: and the class comment of Model for
> further information.
>
> Hope this helps,
>
> Regards.
>
> --
> Esteban.