See sample code
@State private var citiesList: [City]?
var body: some View {
if let cities {
content(cities)
}
else {
AsyncView(
operation: { try await getData(()) },
content: { cities in
contentView(cities)
}
)
}
}
So this works ok. my issue is when adding a code above contentView(cities) since it seems this kind of closure only accepts 1 line, returning a view and does not accept any other code?
like if i add the line
citiesList = cities contentView(cities)
it will say Type '()' cannot conform to 'View'
What is the solution for this?
Or is it possible that the "cities in" part, i can assign it to the citiesList, so that citiesList will be passed to the content(citiesList) method instead of content(cities) ?