ios – What is the difference between Apple’s Provider and Client class when constructing the network layer?

0
118

[ad_1]

I have recently been following Apple tutorials in regards to constructing the network layer for an iOS application.

Below is a diagram of my current network layer in my project.The TaskClient class retrieves the models. The TaskProvider class contains an instance of TaskClient and stores the models. This TaskProvider is an ObservableObject that is injected into the environment. With this ObservableObject I can display these models in the presentation layer and if they are updated the UI refreshes.

I watched a WWDC2022 video Use Xcode for server-side development, they appear to follow the same pattern for code between client and server. At the end of the video they explain what should be next and one being the implementation of adding, deletion and updating.

I would assume that these functions go into the TaskClient and with the TaskProvider class the view can call these operations.

I am trying to understand what the purpose of this Client class is. To me the communication between the client and remote server and the caching can be achieved in the Provider class. What is the difference between the two classes? What was the need for separation?

network layer diagram

[ad_2]