[Cuis-dev] dependency mechanism for TextModelMorph

Weslleymberg Lisboa weslleym.lisboa at gmail.com
Sun Mar 23 09:45:25 PDT 2025


TextModel generates some events. Browse senders of #changed: to see it. Maybe the event that #addDepedent: listens to is not the one you need.

Cuis use the Observer Pattern as a dependency mechanism (see [1]) so #addDependent: and #changed: are "simplifications" of #when:send:to: and #triggerEvent:with:

IMHO if what you need is to be notified of changes in the model, I'd use it directly instead of making TextModelMorph notify me.

1 - <https://github.com/nmingotti/The-Cuis-CookBook/wiki/The-Dependency-Mechanism--3>

Em 23 de março de 2025 11:53:10 BRT, Mark Volkmann via Cuis-dev <cuis-dev at lists.cuis.st> escreveu:
>As far as I can tell, TextModel morph does not send #changed: every time
>its value changes, so that prevents me from listening for updates. I see
>that the TextModel method actualContents: does send #changed:, but that is
>not invoked on every change to a TextModelMorph even when it is configured
>with acceptOnAny: true.
>
>On Sun, Mar 23, 2025 at 9:38 AM <ken.dickey at whidbey.com> wrote:
>
>> On 2025-03-23 06:35, Mark Volkmann via Cuis-dev wrote:
>>
>> > ...
>> > myTextModelMorph addDependent: self.
>> ..
>> >
>> > I have a few questions.
>> > - Are there reasons why I should not want this ability?
>>
>> Generally, Morphs are Views and update to reflect changes in an
>> underlying Model.
>>
>> A Morph can be a Model if sensible.
>>
>> > - Would it be better to listen for changes on the underlying TextModel?
>>
>> IMHO, yes.
>>
>> $0.02,
>> -KenD
>>
>
>
>-- 
>R. Mark Volkmann
>Object Computing, Inc.


--
Att.
Wéslleymberg Lisboa
Graduado em Sistemas de Informação
Docente no IFFluminense - Campus Itaboraí
Ex-Bolsista de IC do Núcleo de Computação Científica (NC2-IFF) - Projeto IFF Aerospace
Github: https://github.com/weslleymberg
Tel.: +55 22 99931-2376
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250323/edc4c191/attachment.htm>


More information about the Cuis-dev mailing list