API design
In this section, we are going to set up our API class. Once we have the respective file, we will use it minimally. I always try to use a simple API design and I feel this is really to the point. Even though we'll be using Combine here a lot more than we have the rest of this book, this won't be excessive and it will be fairly easy for you to understand what's going on. Here, we will create an API class and add some code to our View model that our views will communicate with. Let's jump in and create our API class.
Creating the API class
Here, we need to create an API for every page in this app, which will include the dashboard, roster, schedule, and game details dashboard. First, create a new folder called Networking
and then create a new file named API
. Inside the Networking
folder, update the import
statements to the following:
import Combine import SwiftUI
Next, add the following struct
:
struct API { // Add next step here }
We want...