Reactive Programming in iOS with Combine

Feb 4 2021 · Swift 5.3, macOS 11.0, Xcode 12.2

Part 3: Combining Operators

20. Challenge: Advanced Combining

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 19. Operator Examples Next episode: 21. Conclusion

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

You’ve learned all about Advanced Combining Operators - so now it’s time for a challenge. For this challenge, you’ll build upon the last challenge, where you constructed some modern day phone numbers. This time, however, the data is a bit more complex.


example(of: "Making Phone Numbers") {

  let phoneNumbersPublisher = ["123-4567", "555-1212", "555-1111", "123-6789"].publisher
  let areaCodePublisher = ["410", "757", "800", "540"].publisher
  let phoneExtensionPublisher = ["EXT 901", "EXT 523", "EXT 137", "EXT 100"].publisher

  areaCodePublisher
    .zip(phoneNumbersPublisher)
    .map{$0 + "-" + $1}
    .zip(phoneExtensionPublisher)
    .map{$0 + " " + $1}
    .sink(receiveValue: { print($0) })
    .store(in: &subscriptions)

}