It's a web-services based search application.  I'm basically lazy-
loading search results into a collection in chunks of 20 or so.  The 
chunks may be non-sequential, so I pad the ArrayCollection with empty 
items that are replaced as they become available.  

>From what you're saying, disableAutoUpdate was actually intended to 
work in the other direction - when updating the server with data 
changes from the collection?

As a followup question, I've noticed that bindings in general tend to 
fire more often than I'd expect.  In some cases, 4 times for one 
update.  Can you offer some general ideas on what might cause 
bindings to fire multiple times for a single update?

--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> When the collection is synced to the server, as you edit fields in 
an
> item, you don't want to push it for every field, just once when done
> with the item.
>  
> Clearly if you only change a small % of the items you should not 
reset
> the whole thing.  What are you binding to that gets all the traffic?
> 
> ________________________________
> 
> From: [email protected] 
[mailto:[EMAIL PROTECTED] On
> Behalf Of t0ml33
> Sent: Tuesday, November 27, 2007 1:04 PM
> To: [email protected]
> Subject: [flexcoders] Re: ListCollectionView dispatches too many
> CollectionEvents after enableAutoUpdate
> 
> 
> 
> Thanks for the response, Alex. I understand that for most use 
cases, 
> it would suffice to set a new source. However, I believe that 
> approach somewhat defeats the purpose of databinding. Suppose 
you're 
> bind to an ArrayCollection with 1000 items and you need to change 
> 20? Should you clone the ArrayCollection, change the 20 items, and 
> then rebind? Should you update the existing ArrayCollection and 
have 
> the rest take care of itself? I prefer the latter - it's much 
> cleaner. However, I also don't want my bindings firing 20 times in 
a 
> row.
> 
> Was there a particular use-case in mind when it was decided that 
only 
> update events would be queued? It would help me better understand 
> enable/disableAutoUpdate to know.
> 
> --- In [email protected] <mailto:flexcoders%
40yahoogroups.com>
> , "Alex Harui" <aharui@> wrote:
> >
> > I suppose we should have called it "queueUpUpdatesUntilLater" and
> > "sendAllQueuedUpUpdatees".
> > 
> > 
> > 
> > IMHO, there's an upper limit where, instead of changing 
piecemeal, 
> you
> > should just set a new source, which should just send one big RESET
> > event.
> > 
> > 
> > 
> > ________________________________
> > 
> > From: [email protected] <mailto:flexcoders%
40yahoogroups.com>
> 
> [mailto:[email protected] <mailto:flexcoders%
40yahoogroups.com>
> ] On
> > Behalf Of t0ml33
> > Sent: Wednesday, November 21, 2007 11:58 AM
> > To: [email protected] <mailto:flexcoders%
40yahoogroups.com> 
> > Subject: [flexcoders] ListCollectionView dispatches too many
> > CollectionEvents after enableAutoUpdate
> > 
> > 
> > 
> > I am making some updates to an ArrayCollection. Since it's the 
> > dataSource for a DataGrid, and I want the binding to update as 
few 
> > times as possible, I am using ArrayCollection.disableAutoUpdate
(), 
> > making the changes, and then calling enableAutoUpdate() thinking 
> that 
> > this will cause the binding to refresh only once for all the 
> > changes. This would be the case if the ArrayCollection were 
> > dispatching events of kind CollectionEventKind.UPDATE. Alas, 
since 
> I 
> > am replacing the items in the ArrayCollection and not merely 
> updating 
> > them, it is CollectionEventKind.REPLACE. As you can see from 
> > handlePendingUpdates() in ListCollectionView, it only gangs the 
> > updates into a single refresh if the event.kind == 
> > CollectionEventKind.UPDATE. All other CollectionEvents are fired 
> > sequentially, which would seem to defeat the purpose of 
> > disableAutoUpdate. Could someone clue me in on why this should be 
> > the case? I'm tempted to monkey-patch around it, and submit a 
bug. 
> > See the code below.
> > 
> > Thanks,
> > 
> > -tom
> > 
> > private function handlePendingUpdates():void
> > {
> > if (pendingUpdates)
> > {
> > var pu:Array = pendingUpdates;
> > pendingUpdates = null;
> > 
> > // Could further optimize to consolidate various events
> > // and make a decision if there are too many updates
> > // and we should just refresh.
> > var singleUpdateEvent:CollectionEvent;
> > for (var i:int = 0; i < pu.length; i++)
> > {
> > var event:CollectionEvent = pu[i];
> > 
> > // ****** Here's the offending code
> > if (event.kind == CollectionEventKind.UPDATE)
> > {
> > if (!singleUpdateEvent)
> > {
> > singleUpdateEvent = event;
> > }
> > else
> > {
> > for (var j:int = 0; j < event.items.length; 
> > j++)
> > {
> > singleUpdateEvent.items.push(event.items
> > [j]);
> > }
> > }
> > }
> > else
> > {
> > listChangeHandler(event);
> > }
> > }
> > 
> > if (singleUpdateEvent)
> > {
> > listChangeHandler(singleUpdateEvent);
> > }
> > }
> > }
> >
>


Reply via email to