Last active
April 5, 2020 01:40
-
-
Save jasdev/bdbfb245e2da525d16252310aaaab5ab to your computer and use it in GitHub Desktop.
Implemented `setOutputType`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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