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"] ) ] } }