I'm converting some Combine publishers to async using .values
and trying to understand what happens when:
A Publisher completes before emitting a value.
Here is some example code:
let response = client.fetch(query: query)
.tryMap {
/* map the data, or throw a mapping error if it doesn't map. */
}
return Model()
}
.eraseToAnyPublisher()
.values
for try await result in response {
return result
}
throw AsyncCombineError.finishedWithoutValue // my custom error
What happens with .values
if the publisher completes without emitting any values? It returns a type of AsyncThrowingSequence<Self>
Will it throw? return? hang? or is this state impossible to happen?
Thanks and please enlighten me if I am misunderstanding structured concurrency. This is new to me!