From the course: Learning Combine with Swift

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Abstract Combine implementations with type erasures

Abstract Combine implementations with type erasures - Swift Tutorial

From the course: Learning Combine with Swift

Start my 1-month free trial

Abstract Combine implementations with type erasures

- [Instructor] When you design classes and structs, in Swift, perhaps as a Swift Package SDK, you want to let others consume it, certain methods and properties you make public, whereas others you may not want to make public and expose your inner workings, and you set those to private. We're going to spend a brief moment talking about Type Erasures in Combine, and how they help you Abstract your Implementation. Combine has an equivalent notion of implementation access, called Type Erasures, they enable you to design your Publishers so that you don't have to overexpose its inner workings. Now let's look at some code. In our Exercise File, option click on Publisher. Here you can see what type it discloses, Publisher Decode, Publishers Map, URLSession, data Task Publisher, as well as Array Post and JSONDecoder quite detailed. As you can see, it is a Data Task Publisher, and we're decoding a JSON and outputting an Array of type…

Contents