Does Publisher.first complete after sending a value?

I would like the first() operator to send a value as soon as it's received a value that satisfies the condition (and to finish publishing as well). But I don't know how to test this is really happening. The only test I've devised is below, but I suspect it is wrong. The map operator will keep demanding values of course, so I expect it to print all of them. Yet the sink subscriber doesn't invoke receiveValue or receiveCompletion until after map is done, which suggests first is awaiting upstream completion. Does first really does need the upstream to complete before it sends anything onward? What's really the story here for first?

Code Block
import Foundation
import Combine
let numbers = (-10...10)
let cancellable = numbers.publisher
    .map({ n in
        Thread.sleep(forTimeInterval: 1)
        print("sending \(n)")
        return n
    })
    .first { $0 > 0 }
    .sink { completion in
        switch completion {
        case .failure(_): print("failed")
        case .finished: print("finished")
        }
    } receiveValue:  { print("\($0)") }


My specific situation is I'm monitoring for when the network becomes available the first time. Of course the monitoring source will never (should never) finish but I do want completion for a pipeline subscribing to that monitor with first.

First does send a completion when it's triggered, although I suspect for this use case what you want is actually firstWhere, which looks for a specific predicate to trigger on before sending values - where first just takes whatever it gets right off the bat (meaning you had to filter the content earlier in the pipeline). The difference is minimal - when used inline it just looks like a parameter to the first operator, but they're different structs under the covers.

While I was working on a my own reference content for Combine, I wrote a bunch of tests that worked all the various operators, so if you're so inclined, you can see what I did there to test the first operator - it's open source.

Does Publisher.first complete after sending a value?
 
 
Q