8000 refactor: initialize event listeners once · rubythonode/nativescript-vue@88de73d · GitHub
[go: up one dir, main page]

Skip to content

Commit 88de73d

Browse files
committed
refactor: initialize event listeners once
1 parent dfa5997 commit 88de73d

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

platform/nativescript/runtime/components/list-view.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,7 @@ export default {
2424
'native-list-view',
2525
{
2626
ref: 'listView',
27-
on: {
28-
itemLoading: this.onItemLoading,
29-
itemTap: args =>
30-
this.$emit(
31-
'itemTap',
32-
Object.assign({ item: this.items[args.index] }, args)
33-
),
34-
loaded: args => this.$emit('loaded', args),
35-
unloaded: args => this.$emit('unloaded', args),
36-
loadMoreItems: args => this.$emit('loadMoreItems', args)
37-
},
27+
on: this._on,
3828
domProps: {
3929
items: this.items,
4030
separatorColor: this.separatorColor
@@ -54,6 +44,20 @@ export default {
5444
}
5545
},
5646

47+
created() {
48+
this._on = {
49+
itemLoading: this.onItemLoading,
50+
itemTap: args =>
51+
this.$emit(
52+
'itemTap',
53+
Object.assign({ item: this.items[args.index] }, args)
54+
),
55+
loaded: args => this.$emit('loaded', args),
56+
unloaded: args => this.$emit('unloaded', args),
57+
loadMoreItems: args => this.$emit('loadMoreItems', args)
58+
}
59+
},
60+
5761
mounted() {
5862
this.getItemContext = (item, index) =>
5963
getItemContext(item, index, this.$props['+alias'], this.$props['+index'])

0 commit comments

Comments
 (0)
0