Created
September 24, 2021 18:41
-
-
Save dmytro-anokhin/20126b5ef641bdebc1216299c9cf3b5c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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