dave08
01/26/2022, 12:51 PM@get:[Provides Named("foo") Singleton]
val foo: Deferred<String?> = GlobalScope.async { ... }
gildor
01/27/2022, 5:24 AM@Provides @IntoSet @Named("OnAppCreate")
fun provideFoo(): () -> Unit = ...
And inject like:
@Named("OnAppCreate")
val onCreateActions: Set<() -> Unit>
fun onCreate() {
onCreateActions.onEach { it() }
}
dave08
01/27/2022, 1:51 PMDeferred
somewhere else and await()
it... I'm hoping that from the application's start till I actually need it, I'll already have access to the ready result...gildor
01/27/2022, 2:02 PMdave08
01/27/2022, 2:06 PMgildor
01/27/2022, 2:08 PMdave08
01/27/2022, 2:13 PMgildor
01/28/2022, 1:57 AMavoiding getting to the function limit before multidexBut you create new class even here, this async block lambda is a new class too
So just to make the interaction with the shell, it’s better to even create a single method class?It’s definitely doesn’t look as a work for DI for me, essentially you using an external tool inside and even cache result of it Class is easier to extend, it encapsulates logic, it can be tested and also has more friendly API for client code, you inject it by name and call a function with some meningful name instead of just Deferred<String> with qualifier