Created
December 12, 2021 13:22
-
-
Save michzio/668da2edf36cf2dc03bf5dcf53107a9c to your computer and use it in GitHub Desktop.
SwiftUI MVVM architecture - Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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