Posted by
Günther Schmidt on
Jan 17, 2005; 10:11am
URL: https://forum.world.st/ListModel-observer-on-its-listitems-tp3372732p3372734.html
Yar Hwee Boon schrieb:
> On Mon, 17 Jan 2005 10:42:25 +0100, Günther Schmidt
> <
[hidden email]> wrote:
>
>> can a listmodel be set to be an events observer of its items?
>>
>> Maybe in a similar fashion like a set with a sortBlock:?
>>
>> Like when an item is added send
>>
>> ListModel add: anItem
>> anItem when:#someEvent send:#updateItem: to: self "ListModel"
>> with: anItem
>
>
>> and:
>>
>>
>> ListModel removeItem: anItem
>>
>> anItem removeEventsTriggeredFor: self
>
>
> Why do you want to do this?
>
A listmodel is usually attached to a listPresenter, and the
listpresenter receives update events from the listmodel, when the *list*
changes, ie. when items are added or removed, but not when an item is
updated.
At least not for all that I've been able to figure sofar.
In the personalmoney application this problem doesn't occur, because
when a transaction gets updated, it is temporarily removed from the
list, which triggers the first update event to the listpresenter, and
then reinserted into the list, which triggers the second update event
for the list presenter.
In other words, the model (the list of transactions in this case) is
altered mereley for the purpose of updating the view, and I'm just not
sure I want to do it this way.
Günther