Skip to content

Instantly share code, notes, and snippets.

@thexande
Last active December 16, 2018 04:44
Show Gist options
  • Save thexande/c19a0404e6e8f8393383fab4effbf7a3 to your computer and use it in GitHub Desktop.
Save thexande/c19a0404e6e8f8393383fab4effbf7a3 to your computer and use it in GitHub Desktop.
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