This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Observer Pattern problem  RSS feed

 
Tim Nachreiner
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem begins when the controller calls createAndShowPerson.
The controller listens to the model. When the model creates a new Person, I want the controller to be notified. However, in the model.createPerson method, the notifyModelListener method is out of range. I can't figure out how to get around this problem.



 
Tim Nachreiner
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved it with this:

 
Dave Tolls
Ranch Hand
Posts: 2818
30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens in createAndShowPerson now?
You were using the returned Person to set the Controller's Person attribute.
 
Tim Nachreiner
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now my controller doesn't expect to get anything back from the model.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!