Andreas Sinz
02/19/2018, 11:32 AMinterface FooTags {
fun getTags(): Map<String, Int>
}
class FooTagsRetriever : FooTags {
override fun getTags(): Map<String, Int> {
//Get Tags via HTTP
}
}
class FooTagsCache(private val retriever: FooTags): FooTags {
private lateinit var tagCache: Map<String, Int>
override fun getTags(): Map<String, Int> {
If(!::tagCache.isInitialized) {
tagCache = retriever.getTags())
}
return tagCache
}
Then you have transparent caching and can easily test every part in isolationmplacona
02/19/2018, 12:04 PM!::
do? I get "!" is NOT, but what does the ::
after that do?Andreas Sinz
02/19/2018, 12:52 PMtagCache
-property: https://kotlinlang.org/docs/reference/reflection.html#property-referencesmplacona
02/19/2018, 12:53 PM