DelayedObservableValue with IObservableCollection? [message #629869] |
Wed, 29 September 2010 19:30 |
Peer Törngren Messages: 14 Registered: July 2009 Location: Sweden |
Junior Member |
|
|
Problem; I bind two properties using an observable list. When adding elements to the observed collection (myCollection.addAll(newEelements)), the observer receives one event for each added element. Alas, adding 3000 elements takes time, especially since the observer takes action on each event.
A simple solution would be to use a delay, i.e. wait until all elements have been added before firing the event. This approach works really nice when observing SWT controls or JFace viewers, and there is a way to observe distinct values with a delay. But I cannot find a corresponding mechanism for collections?
The closest I get is 'org.eclipse.core.databinding.observable.Observables.observe DelayedValue(int, IObservableValue)' which uses the 'org.eclipse.core.internal.databinding.observable.DelayedObs ervableValue'. But as far as I can understand, this is not usable for collections; it requires an 'IObservableValue', whereas 'IObservableCollection' extends 'IObservable'.
Questions are:
1) can I use 'observeDelayedValue(...)' to observe collections? If so, how?
2) is there some other (simple) way to avoid firing events on each element being added to an observed collection?
3) or am I doing something wrong? Should 'addAll()' on an observed collection fire one event for each added element?
BTW, I found a similar comment on the EMF forum ( http://www.eclipse.org/forums/index.php?t=tree&th=168440 &S=d73708f3b6a1ea1a4e89fbb7655baf47.
I can probably work my way around this, but before I do that I just want to make sure I'm not missing something obvious.
regards
Peer
|
|
|
Re: DelayedObservableValue with IObservableCollection? [message #630724 is a reply to message #629869] |
Mon, 04 October 2010 16:52 |
Matthew Hall Messages: 368 Registered: July 2009 |
Senior Member |
|
|
There is an open feature request for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=269728
Matthew
On 09/29/2010 01:30 PM, Peer T wrote:
> Problem; I bind two properties using an observable list. When adding
> elements to the observed collection (myCollection.addAll(newEelements)),
> the observer receives one event for each added element. Alas, adding
> 3000 elements takes time, especially since the observer takes action on
> each event.
>
> A simple solution would be to use a delay, i.e. wait until all elements
> have been added before firing the event. This approach works really nice
> when observing SWT controls or JFace viewers, and there is a way to
> observe distinct values with a delay. But I cannot find a corresponding
> mechanism for collections?
>
> The closest I get is
> 'org.eclipse.core.databinding.observable.Observables.observe
> DelayedValue(int, IObservableValue)' which uses the
> 'org.eclipse.core.internal.databinding.observable.DelayedObs
> ervableValue'. But as far as I can understand, this is not usable for
> collections; it requires an 'IObservableValue', whereas
> 'IObservableCollection' extends 'IObservable'.
> Questions are:
> 1) can I use 'observeDelayedValue(...)' to observe collections? If so, how?
> 2) is there some other (simple) way to avoid firing events on each
> element being added to an observed collection?
> 3) or am I doing something wrong? Should 'addAll()' on an observed
> collection fire one event for each added element?
>
> BTW, I found a similar comment on the EMF forum
> ( http://www.eclipse.org/forums/index.php?t=tree&th=168440 &S=d73708f3b6a1ea1a4e89fbb7655baf47
>
>
> I can probably work my way around this, but before I do that I just want
> to make sure I'm not missing something obvious.
>
> regards
> Peer
|
|
|
Powered by
FUDForum. Page generated in 0.02497 seconds