Access source in ListEventListener

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Access source in ListEventListener

Fabian Zeindl
Hi,

 is it safe to use the indices from the ListEvent to access to the source list inside the ListEventListener.
(Since the indices change while I iterate through the blocks)

Fabian
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Access source in ListEventListener

robeden
Can you give a short example of what you're trying to do?

On Wed, Jan 4, 2017 at 1:27 AM Fabian Zeindl <[hidden email]> wrote:
Hi,

 is it safe to use the indices from the ListEvent to access to the source list inside the ListEventListener.
(Since the indices change while I iterate through the blocks)

Fabian
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Access source in ListEventListener

Fabian Zeindl
I have a GridView that displays a list of items, wrapped to some viewport.
It listens on an EventList and calls a function on each inserted item to get it's dimensions.

I only realised now that I can use get*Value etc. for this.
In earlier projects I just used the index from the ListEvent to get the item out of the source list, the one I hooked up the listener.

It always seemed to work though?

> On 5 Jan 2017, at 17:41 , Rob Eden <[hidden email]> wrote:
>
> Can you give a short example of what you're trying to do?
>
> On Wed, Jan 4, 2017 at 1:27 AM Fabian Zeindl <[hidden email]> wrote:
> Hi,
>
>  is it safe to use the indices from the ListEvent to access to the source list inside the ListEventListener.
> (Since the indices change while I iterate through the blocks)
>
> Fabian

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Access source in ListEventListener

robeden
I believe you should always be able to use an insertion index to get the item from the source list. (That's the reason for the ascending order requirement on events mentioned previously on the list.) The source list will have processed the insert prior to the event being dispatched.

The getNewValue() method is lightweight to implement so there's no problem there. It doesn't really make sense for blocks though. So, I think you can count on it being there though the API might change. Personally, I'd use the index and access the source since the get*Value() methods are beta/deprecated/despised by some.

On Thu, Jan 5, 2017 at 12:32 PM Fabian Zeindl <[hidden email]> wrote:
I have a GridView that displays a list of items, wrapped to some viewport.
It listens on an EventList and calls a function on each inserted item to get it's dimensions.

I only realised now that I can use get*Value etc. for this.
In earlier projects I just used the index from the ListEvent to get the item out of the source list, the one I hooked up the listener.

It always seemed to work though?

> On 5 Jan 2017, at 17:41 , Rob Eden <[hidden email]> wrote:
>
> Can you give a short example of what you're trying to do?
>
> On Wed, Jan 4, 2017 at 1:27 AM Fabian Zeindl <[hidden email]> wrote:
> Hi,
>
>  is it safe to use the indices from the ListEvent to access to the source list inside the ListEventListener.
> (Since the indices change while I iterate through the blocks)
>
> Fabian

Loading...