-
-
Notifications
You must be signed in to change notification settings - Fork 158
Updated documentation for list-view #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Deploy preview for nativescript-vue ready! Built with commit 8874a3c |
|
||
The ListView does not loop through the items as you would expect when using a [`v-for`](https://vuejs.org/v2/guide/list.html#Mapping-an-Array-to-Elements-with-v-for) loop. Instead it only creates the necessary views to display the currently visible items on the screen, and when scrolling it reuses the views that are already off-screen. This concept is called view recycling, and is commonly used in mobile applications to improve performance. This is important because you can't rely on event listeners attached inside the `v-template`, instead you should use the `itemTap` event which contains the index of the tapped item, as well as the actual item from the list. | ||
When you use `<ListView>` with [`v-for`](https://vuejs.org/v2/guide/list.html#Mapping-an-Array-to-Elements-with-v-for), you need to use the default `itemTap` event instead of attaching other event listeners. The `itemTap` event contains the index of the tapped item and the actual item from the list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this back to the previous version, because the two are a bit different. What the old version means is that the ListView works differently that if you were using v-for
(nativescript-vue will issue a warning when a v-for
is used in a list view), and due to the different mechanism (view recycling) you can't rely on events inside a v-template
.
Although this may no longer be true, because if you don't have an itemTap
event handler, then you can do custom events inside v-template
, which is useful in cases where you may have a few actions for every list item (think of the like/retweet etc buttons in a tweet list view for example).
|
||
| Name | Description | | ||
|------|-------------| | ||
| `refresh()` | Forces the `<ListView>` to reload all its items. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method doesn't actually exist in this form, only on the underlying native element, however we can add it to make things easier, so keep it here, but maybe add a (soon)
note next to it, I've opened the issue here to track progress
nativescript-vue/nativescript-vue#193
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Updated as requested 🦄 |
No description provided.