#trigger: and #when: send: to:

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

#trigger: and #when: send: to:

keith
Hi,
I'm just getting started with Dolphin, and have a question about
#trigger: and #when:send:to: selectors.

I'm trying to signal an event in a model that will be detected by the
presenter associated with the model. In my model, I do something like
this--

MyModel>>doSomethingUseful
   "yada yada"
   self trigger: #myImportantInfo.

In my Presenter --
MyPresenter>>createSchematicWiring
   super createSchematicWiring.
   self model when: #myImportantInfo send: #doMyThing to: self.

My problem: when doSomethingUseful is invoked, it doesn't cause the
desired effect for my presenter....doMyThing is never called. Am I
missing something here, or is #trigger: not a general-purpose
notification mechanism? If not, how does one create user-defined
events?

Thanks for the help...

Keith


Reply | Threaded
Open this post in threaded view
|

Re: #trigger: and #when: send: to:

Ian Bartholomew-12
Keith,

> My problem: when doSomethingUseful is invoked, it doesn't cause the
> desired effect for my presenter....doMyThing is never called. Am I
> missing something here, or is #trigger: not a general-purpose
> notification mechanism? If not, how does one create user-defined
> events?

The description you gave should work and is the correct way to define
events.  There are a number of things that can cause it to stop working
though - some suggestions (no particular order)

- You've a difference in spelling between the trigger and target events
(seems obvious I know but for some reason it can be difficult to spot)
- You are changing the model. If you register for the trigger with a
specific model instance but then change that instance (using
Presenter>>model:) the new model object will need to have the event
trigger registered.  This also applies if you set the presenter's model
yourself and don't use #defaultModel.
- You have overridden #onViewOpened (or maybe one of the other creation
methods) and haven't done a supersend. This can result in
#createSchematicWiring not being evaluated.

The easiest way to narrow down the problem is to stick breakpoints in the
various places (including the presenters #createSchematicWiring) and see
which is the first that is not reached.

--
Ian
Due to spamming the reply-to address may only be valid for the next few
days.  Use it to mail me _now_ if you want a longer term contact address.