-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathhome-view-model.js
More file actions
32 lines (26 loc) · 742 Bytes
/
home-view-model.js
File metadata and controls
32 lines (26 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// app/home/home-view-model.js
// Update this 👇
import { Frame, Observable, ObservableArray } from '@nativescript/core'
import { FlickService } from '../services/flick.service'
// Add the contents of HomeViewModel class 👇
export class HomeViewModel extends Observable {
#flicks;
constructor() {
super()
this.populateFlicks()
}
// this will be used as the data source of our ListView
get flicks() {
return new ObservableArray(this.#flicks)
}
populateFlicks() {
this.#flicks = FlickService.getInstance().getFlicks();
}
// Add this 👇
onFlickTap(args) {
Frame.topmost().navigate({
moduleName: 'details/details-page',
context: { flickId: this.#flicks[args.index].id }
})
}
}