For Android: I have
- a core library with some basic functions: libCore . libCore is written is Java and contains some basic functions with calculations, does not contain any Android related libraries, pure Java. It has an interface offering those functions to the outer ring
- a library, what suses this core: libModule . libModule is written in Kotlin and is an Android library. libModule imports libCore and combines those basic calculations to more complex functions.
- finally my Android App : myApp . myApp is an Android App written also in Kotlin, this just imports libModule and not libCore. On this level we want to hide libCore stuff and do want to see any libcore stuff here..
I have a battery of callbacks from libModule to myApp, which I combined in the meanwhile to some Wrapper classes. Example:
class LoginCallbackWrapper {
internal lateinit var authenticationCallback : AuthenticationCallback
internal lateinit var loginCallback : LoginCallback
internal lateinit var andDozenOtherCallback: DozenOtherCallbacks
val isAuthInitialized = fun(): Boolean{
return ::authenticationCallback.isInitialized
}
//.. also for the other callbacks
}
Further I have other CallbackWrapper with combined Callbacks.
I was hopeing there is another more elegant way for these amount of callbacks? Any design pattern, another library.. I've heard something about Dagger2. So maybe with dependency injection?