bakerac4 / glimmer-native

77 stars 5 forks source link

ListView Issues #24

Open bakerac4 opened 4 years ago

bakerac4 commented 4 years ago

ListView/RadListView have quickly become THE major thorn in my side while testing Glimmer Native out. We need to use ListView/RadListView because they provide native view recycling. Without them, rendering a large list of items would kill the app on the phone or at the very least slow it down greatly.

The following issues need to be fixed before a 1.0 release can happen

Along with specifying a template inline, I think it would be beneficial to give the user the option to user a real component. Currently this is how we do things, but there are downsides I haven't been able to solve.

lifeart commented 4 years ago

regarding tracked properties won't work, maybe it may help https://gist.github.com/lifeart/d6237e0129e603b23d1aa8e8d4b07504 ? way to make any object tracked

lifeart commented 4 years ago

is it possible to use yield for templating? like

<RadListView @items={{dataItems}} @itemComponent="component-name" as  |ItemComponent|>
 <ItemComponent>
      <StackLayout orientation="vertical">
            <Label class="nameLabel" [text]="item.name"></Label>
            <Label class="descriptionLabel" [text]="item.description"></Label>
        </StackLayout>
</ItemComponent>
</RadListView>

and inside RadListView template, do


{{#each @items @key="id" as |item|}}
   {{yield (component @itemComponent) item}}
{{/each}}
bakerac4 commented 4 years ago

@lifeart yielding isn't possible due to the fact that the list view is recycling items with views. So there is no each that gets called or rendered. What happens is that Nativescript calls for an item to be created and then https://github.com/bakerac4/glimmer-native/blob/master/src/dom/native/RadListViewElement.ts#L31 gets called.