Created
January 30, 2020 08:46
-
-
Save ramunasjurgilas/745110630725759661f14b3b2f1b853a to your computer and use it in GitHub Desktop.
map(_:) KeyPath as transforming operator
This file contains hidden or 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
struct Person { | |
let firstName: String | |
let lastName: String | |
} | |
let publisher = PassthroughSubject<Person, Never>() | |
publisher | |
.map(\.firstName, \.lastName).sink { | |
print("\($0) \($1)") | |
} | |
let person = Person(firstName: "Jackie", lastName: "Chan") | |
publisher.send(person) | |
// Output: | |
// Jackie Chan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment