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

Lesson Complete

Play Next Lesson
Next
Save for later
About this episode

See course reviews

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

This video was last updated on Feb 4 2021

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

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)

}