Problem with ObservedList Announcements

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with ObservedList Announcements

Travis Griggs-2
I'm short on sleep here, so maybe I've missed the obvious.

An ObservedList has a variety of Announcements it produces. For all  
and any change to the list contents, it uses the ValueAboutToChange/
ValueChanging/ValueChanged pattern, just like a simple ObservedValue  
would. But it also might announce something like a ElementsReplaced  
if you do an at:put:

So I have this view hooked up to an ObservedList. The fallback case  
is that if I get a ValueChanged, redraw the whole view. But I'd like  
to make the view a little more efficient. When someone does an  
at:put:, ideally I just redraw the part of the view that is relative  
to that index. So I could subscribe to the ElementsReplaced. But the  
rub is... how do I set up my view to respond to an ElementsReplaced  
when it happens and ignore the associated ValueChanged, but still  
respond to the ValueChanged when it's not in conjunction with an  
ElementsReplaced?

--
Travis Griggs
Objologist
Time and Countertops. They both get used up way too fast.


Reply | Threaded
Open this post in threaded view
|

Re: Problem with ObservedList Announcements

Vassili Bykov
Travis Griggs wrote:
> So I have this view hooked up to an ObservedList. The fallback case is
> that if I get a ValueChanged, redraw the whole view. But I'd like to
> make the view a little more efficient. When someone does an at:put:,
> ideally I just redraw the part of the view that is relative to that
> index. So I could subscribe to the ElementsReplaced. But the rub is...
> how do I set up my view to respond to an ElementsReplaced when it
> happens and ignore the associated ValueChanged, but still respond to the
> ValueChanged when it's not in conjunction with an ElementsReplaced?

The sequence is:

        ValueAboutToChange
        ValueChanging
        ElementsReplaced
        ValueChanged

(and I tried to have it consistent for all such cases in that
ValueChanged is always the last--if any are not, let me know).

So one solution is to have a flag 'ignoreNextValueChanged' that you set
when responding to ElementsReplaced and on receipt of ValueChanged you
don't redraw if it's set (and reset the flag).


--
Vassili Bykov <[hidden email]>

[:s | s, s printString] value: '[s: | s, s printString] value: '