I'm trying to get rid of optional fields in my class using Combine.
I have two publishers:
let buttonTapPublisher = PassthroughSubject<Void, Never>()
let stringPublisher = PassthroughSubject<String, Never>()
I need to build a pipeline that receives value from a second publisher, but triggered by first. I tried using combineLatest
, but in this case sink
is "triggered" by both publishers.
Example of the result that I'm trying to achieve:
<pipeline>
.sink { string in
print(string) // prints "hi" once and that's it
}
buttonTapPublisher.send()
stringPublisher.send("hi")
buttonTapPublisher.send()
stringPublisher.send("hello")