Skip to content

Instantly share code, notes, and snippets.

@aasitnikov
Created May 2, 2020 10:10
Show Gist options
  • Save aasitnikov/4a6c68b16f070641e132dbec05bbff90 to your computer and use it in GitHub Desktop.
Save aasitnikov/4a6c68b16f070641e132dbec05bbff90 to your computer and use it in GitHub Desktop.
class KotlinCircularComponent : CircularComponent {
private val apiServiceProvider = DelegateFactory<ApiService>()
private val authenticatorProvider = { Authenticator(createLazy(apiServiceProvider)) }
private val httpClientProvider = { HttpClient(authenticatorProvider()) }
init {
val delegate = createSingleton { ApiService(httpClientProvider()) }
DelegateFactory.setDelegate(apiServiceProvider, delegate)
}
override fun getApiService(): ApiService = apiServiceProvider()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment