Hi Pharo friends,

TL;DR: How should one open a presenter on a user-specified model?  Is 
SpPresenterWithModel>>setAnnouncingObject: missing a call to modelChanged?

The long version:
I am trying to write a UI for my threat modeling tool using Spec in Pharo 8.  I 
had trouble getting my first presenter to show me my model.  My current VERY 
WIP tiny code is available from g...@github.com:octotrike/groundhog.git, on 
branch pharo-sp-presenter-question.

I wanted to do something like this (paraphrased from the class comment for my 
BLFunctionPresenter class):

BLFunctionPresenter new
   model: aModel; 
   openWithSpec

Unfortunately, the UI continued to show the default announcingObject (nil), 
even though announcingObject had changed as expected.

The examples I found showed either
- a containing presenter getting an event, changing instance variables on a 
presenter it contains, and sending modelChanged, or
- a presenter hard coded to show a model that is globally accessible.

In the end, I added self modelChanged to the end of 
SpPresenterWithModel>>setAnnouncingObject:.  It seemed like this method changed 
announcingObject and registered this presenter to receive modelChanged every 
time changes to the announcingObject occurred.  However, in cases like the one 
I am describing, the change is replacement of the entire announcingObject, so 
no announcingObject sends modelChanged.

Was/is this a bug in Spec?  Or is there something else I should be doing to 
open a Spec UI on a model that is neither global nor specified by a parent 
presenter?

Bren



Reply via email to