import { ObservableArray } from "tns-core-modules/data/observable-array" ; import { ListViewEventData } from "nativescript-ui-listview" ; import { Observable } from "tns-core-modules/data/observable" ; const names = require ( "../listview-selection/PhotosWithNames.json" ) ; export class ViewModel extends Observable { constructor ( ) { super ( ) ; this . initDataItems ( ) ; } get dataItems ( ) : ObservableArray < DataItem > { return this . get ( "_dataItems" ) ; } set dataItems ( value ) { this . set ( "_dataItems" , value ) ; } public onItemReordered ( args ) { console . log ( "Item reordered. Old index: " + args . index + " " + "new index: " + args . data . targetIndex ) ; } private initDataItems ( ) { this . dataItems = new ObservableArray < DataItem > ( ) ; for ( let i = 0 ; i < names . names . length ; i ++ ) { this . dataItems . push ( new DataItem ( names . names [ i ] ) ) ; } } } export class DataItem { public itemName ; constructor ( name ) { this . itemName = name ; } }