Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Xamarin.Forms

You're reading from   Mastering Xamarin.Forms Build rich, maintainable, multi-platform, native mobile apps with Xamarin.Forms

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher
ISBN-13 9781788290265
Length 192 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Ed Snider Ed Snider
Author Profile Icon Ed Snider
Ed Snider
Roberto Hernandez Roberto Hernandez
Author Profile Icon Roberto Hernandez
Roberto Hernandez
Arrow right icon
View More author details
Toc

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 that 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. To create a data service for the TripLog API, perform the following steps:

  1. Create a new interface named ITripLogDataService in the Services folder of the core library:
      public interface ITripLogDataService...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime