I am trying to figure out a way to insert multiple arrays of views in a VStack in SwiftUI using collect() operator.
struct ChatsTab: View {
var subscriptions = Set<AnyCancellable>()
var body: some View {
VStack {
["A", "B", "C", "D", "E"].publisher.collect(2).sink(receiveCompletion: { _ in
// Do nothing on completion
}) { (stringArray) in
HStack {
Text(stringArray[0])
Text(stringArray[1])
}
}
.store(in: &subscriptions)
}
}
}
But I'm getting this below error:
Cannot convert value of type '()' to closure result type '_'
I want to do this with collect only so I can add my text views in pair. I know I have other options but I want to get it done with collect only.