Skip to content

Instantly share code, notes, and snippets.

@dmytro-anokhin
Created September 24, 2021 18:41
Show Gist options
  • Save dmytro-anokhin/20126b5ef641bdebc1216299c9cf3b5c to your computer and use it in GitHub Desktop.
Save dmytro-anokhin/20126b5ef641bdebc1216299c9cf3b5c to your computer and use it in GitHub Desktop.
actor CitiesCache {
let source: CitiesSource
init(source: CitiesSource) {
self.source = source
}
var cities: [String] {
if let cities = cachedCities {
return cities
}
let cities = source.loadCities()
cachedCities = cities
return cities
}
private var cachedCities: [String]?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment