blob: f1b95e5626770447a2d78d67eaf48365f16bc0bf (
plain) (
blame)
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
33
34
35
|
import Foundation
class HomeViewModel: ObservableObject {
@Published var torrents: ListTorrentResponse = []
var timer: Timer?
init() {
timer = Timer.scheduledTimer(
withTimeInterval: 1,
repeats: true,
block: { _ in
self.refresh()
}
)
}
deinit {
timer?.invalidate()
}
func refresh() {
let randomFloat = Float.random(in: 1 ..< 100)
torrents = [
Torrent(
name: "foo",
completionPercent: randomFloat, ratio: 0,
rateDownload: 1,
rateUpload: 1,
labels: ["foo", "bar"]
)
]
}
}
|