Creating an API Data Service
Using BaseHttpService
as a foundation that abstracts away the HTTP request details, we can now begin to create services that leverage it to get responses back from the API in the form of domain-specific models. Specifically, we will create a data service that can be used by the ViewModels to get the TripLogEntry
objects from the backend service.
We will start off by defining an interface for the data service that can be injected into the ViewModels, ensuring there is no strict dependency on the API or the logic that communicates with it, continuing the pattern we put in place in Chapter 4, Platform Specific Services and Dependency Injection.
- Create a new interface named
ITripLogDataService
in theServices
folder in the ...
Get Mastering Xamarin.Forms now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.