PassthroughSubject is a type of Subject in Combine framework which shares similarity with CurrentValueSubject, but with a clear distinction in the way it takes and sends values. Here's an example of how to create and use a PassthroughSubject:
main.swift715 chars31 linesIn the above example, we create a PassthroughSubject that publishes String values and error of type MyError. We then subscribe to the subject using the sink() operator which prints out the received completion and value events. Finally, we send a value and completion to the subject before canceling the subscription.
Note that unlike CurrentValueSubject, the PassthroughSubject doesn't have an initial value and doesn't store the most recently received value. When you subscribe to the PassthroughSubject, you only receive any subsequent values that are sent to it.
gistlibby LogSnag