mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-05-28 13:18:19 +00:00
26 lines
755 B
Swift
26 lines
755 B
Swift
|
import SwiftUI
|
||
|
import Models
|
||
|
import Network
|
||
|
|
||
|
@MainActor
|
||
|
class ExploreViewModel: ObservableObject {
|
||
|
var client: Client?
|
||
|
|
||
|
@Published var trendingTags: [Tag] = []
|
||
|
@Published var trendingStatuses: [Status] = []
|
||
|
@Published var trendingLinks: [Card] = []
|
||
|
|
||
|
func fetchTrending() async {
|
||
|
guard let client else { return }
|
||
|
do {
|
||
|
async let trendingTags: [Tag] = client.get(endpoint: Trends.tags)
|
||
|
async let trendingStatuses: [Status] = client.get(endpoint: Trends.statuses)
|
||
|
async let trendingLinks: [Card] = client.get(endpoint: Trends.links)
|
||
|
|
||
|
self.trendingTags = try await trendingTags
|
||
|
self.trendingStatuses = try await trendingStatuses
|
||
|
self.trendingLinks = try await trendingLinks
|
||
|
} catch { }
|
||
|
}
|
||
|
}
|