haxeui icon indicating copy to clipboard operation
haxeui copied to clipboard

Review listview/datasources

Open ianharrigan opened this issue 9 years ago • 3 comments

This seems to be a bottle neck and could do with a new implementation.

Telemetry would be needed first, via either hxScout or GameConsole

ianharrigan avatar Jun 05 '15 05:06 ianharrigan

Just wanted to chime in on this;

I'm mostly using listviews / datasources with dynamic items being changed, added and removed all the time. For convience i'm using a set of functions for these tasks:

inline function setDataSourcePosition(source:IDataSource, index:Int) {
    if (index >= source.size())
        return;

    var iterator:Int = 0;                   
    source.moveFirst();
    while (iterator < index) {          
        source.moveNext();
        iterator++;
    } 
}

inline function removeDataSourceItemAt(source:IDataSource, index:Int) {
    setDataSourcePosition(source, index);               
    source.remove();
}

inline function getDataItemAt(source:IDataSource, index:Int):Dynamic {
    setDataSourcePosition(source, index);
    return source.get();
}

But as you can see, this leads to a lot of needless iteration over the datasource. If I don't use the convience functions, I have to write out the iteration snippet for every time I want to manipulate the datasource. It might be an idea to check out the apache flex implementation of datasources / collections / bindable data :

https://git-wip-us.apache.org/repos/asf?p=flex-sdk.git;a=tree;f=frameworks/projects/framework/src/mx/collections;h=621cd28f49d6ef5be839655093ddf3ad46cd6b73;hb=HEAD

with some documentation:

https://flex.apache.org/asdoc/mx/collections/ListCollectionView.html

Mechameesh avatar Aug 14 '15 07:08 Mechameesh

Totally agree, i was actually thinking about doing away with them entirely for version 2, ie the basic listview would just use an array, if you wanted lazy loading that would be an extension of some description LazyListView or whatever.

Thanks for the links though, i might go through them all properly first before i make a decision to drop them

ianharrigan avatar Aug 14 '15 09:08 ianharrigan

I think the main reason to maintain a proper interface to a datasource would be to implement one-way / two-way binding to variables. I haven't given this too much though, but perhaps a IBindable interface for classes that can be bound? Would save a lot of boilerplate code for itemrenderers

Mechameesh avatar Aug 14 '15 12:08 Mechameesh