-
-
Save thexande/c19a0404e6e8f8393383fab4effbf7a3 to your computer and use it in GitHub Desktop.
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
let serverAdress = "https://countries.trevorblades.com/" | |
guard let url = URL(string: serverAdress) else { | |
return nil | |
} | |
let factory = World.Factory() | |
// You will neet to retain the service object with a strong | |
// reference to recieve the callbacks with the data. | |
self.store = factory.makeStore(with: url) | |
// Next, call the service: | |
store.fetchAllCountries(cachePolicy: .returnCacheDataElseFetch) { [weak self] result in | |
switch result { | |
case let .success(countries): | |
// handle data | |
return | |
case let .failure(error): | |
// handle error | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment