Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Implemented `setOutputType`.
extension Publisher where Output == Never {
func setOutputType<NewOutput>(to outputType: NewOutput.Type) /// (1) For the uninitiated, the `.Type`
/// and `.self` suffixes here and at (2) refer to a metatype type and a type as a value,
/// respectively. The language reference has a
/// [solid section](https://docs.swift.org/swift-book/ReferenceManual/Types.html#ID455) on the topic.
-> Publishers.Map<Self, NewOutput> {
map { _ -> NewOutput in }
}
}
Just("someString")
.eraseToAnyPublisher()
.ignoreOutput()
.setOutputType(to: String.self) /// (2) Fixing downstream’s output type to `String`.
.append("anotherStringPostFinished")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.