<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hi Eric,</p>
<p><br>
</p>
<p>for general "reacting to changes", you could an observer pattern. I think this answer from StackOverflow explains it quite well: <a href="https://stackoverflow.com/a/17083241/13994294" class="OWAAutoLink" id="LPlnk798642" previewremoved="true">https://stackoverflow.com/a/17083241/13994294</a> For
 example in Squeak, <span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">you could take a look at the Pluggable morph
 implementations in the </span><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">system categor</span><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">ies</span><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"> Morphic-Pluggable
 Widgets as well as ToolBuilder-Morphic. For instance, in </span><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">PluggableButtonMorph,
 you can see that the communication between morph and model is realized by defining selectors on the morph that will be performed to get necessary data and that can be signaled using the observer pattern to update the visual representation. See PluggableButtonMorph
 >> #update:.</span></p>
<p><br>
</p>
<p>Apart from that, you could also take a look at the "Object Events" pattern in Squeak, see Object >> #when:send:to: + overloads and senders. Personally, I prefer the "normal" observer pattern the most time because it feels less like coupling the morph and
 the model too strong to each other, and it gives you greater flexibility without necessarily defining one selector per event type on the morph class.</p>
<p><br>
</p>
<p>(Last but not least, it would be a possibility to store closures that were generated by the morph in the model and to evaluate them on every change. However, this is usually an anti-pattern because it creates a very strong coupling between the morph and
 the model, so I would not really recommend using this approach ...)<span></span></p>
<p><span><br>
</span></p>
<p><span>To learn more about the underlying design patterns, you could look up in the encyclopedia of your choice the terms "Observer pattern", "MVC", and "MVVM". I hope that helps, and if you have further questions, please don't hesitate to ask them. :-)</span></p>
<p><span><br>
</span></p>
<p><span>Best,</span></p>
<p><span>Christoph</span></p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div>
<div class="_rp_T4" id="Item.MessagePartBody">
<div class="_rp_U4 ms-font-weight-regular ms-font-color-neutralDark rpHighlightAllClass rpHighlightBodyClass" id="Item.MessageUniqueBody" style="font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">
<div dir="ltr">
<div id="divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols">
<div id="Signature">
<div style="margin:0px"><font style="font-family:Calibri,Arial,Helvetica,sans-serif,serif,EmojiFont">
<div><font size="3" color="black"><span style="font-size:12pt"><a href="http://www.hpi.de/" target="_blank" rel="noopener noreferrer" id="LPNoLP"><font size="2"><span id="LPlnk909538"><font color="#757B80"></font></span></font></a></span></font></div>
</font></div>
</div>
</font></div>
</div>
</div>
</div>
</div>
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Eric Gade <eric.gade@gmail.com><br>
<b>Gesendet:</b> Sonntag, 25. Oktober 2020 15:44:12<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> [squeak-dev] Morphs and Data Question</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>Hi all,</div>
<div><br>
</div>
<div>I have a quick question that is perhaps very elementary. What is the best way to design my Morph subclasses so that they "react" to changes on their models? For example, if I have some data related model with text that updates and I want the "view" (the
 Morph) to update whenever this occurs? In my own quick code I've always just implemented a `step` method that checks for data on the model updates, but is that too brutal and inefficient?</div>
<div><br>
</div>
<div>Thanks,<br>
</div>
<div><br>
-- <br>
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div>Eric</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>