hey yasuhiro 😄
quick question, how would you use asyncFirst
in the case where you don't want to cancel the slower functions? as as illustrative example:
func getAPIModel() async throws -> APIModel {
try await asyncFirst([
{ try await self.fetchFromCache(for: id) },
{
let fromAPI = try await self.fetchFromAPI(for: id)
await self.setCached(id, fromAPI)
},
])()
}
even if the first function to fetch from the cache succeeds, i don't want to cancel the second function, i still want to update the cache from the API request.
maybe async isn't the best way to compose this problem, and this is better suited to a Publisher that first gives the cached value if it exists, then the object from the API?