Skip to content

Instantly share code, notes, and snippets.

@michzio
Created December 12, 2021 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michzio/668da2edf36cf2dc03bf5dcf53107a9c to your computer and use it in GitHub Desktop.
Save michzio/668da2edf36cf2dc03bf5dcf53107a9c to your computer and use it in GitHub Desktop.
SwiftUI MVVM architecture - Service
public protocol WordsetServiceProtocol {
func getCategories(from fromLang: String, to toLang: String) -> AnyPublisher<[WordsetCategoryDTO], Error>
}
public final class WordsetService: BaseService, WordsetServiceProtocol {
func getCategories(from fromLang: String, to toLang: String) -> AnyPublisher<[WordsetCategoryDTO], Error> {
let endpoint = Router.wordsetCategories(fromLang: fromLang, toLang: toLang)
let xml : AnyPublisher<WordsetCategoriesDTO, Error> = request(endpoint)
return xml.map(\.categories).eraseToAnyPublisher()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment