https://kotlinlang.org logo
#android
Title
# android
q

Qamar Khan

02/14/2023, 10:59 AM
Hello Dear member, I am looking for a solution , my problem is // this class is in a module Auth sealed class AuthEvent{ .. contains different data class and object class } // this class is in module Dashboard sealed class DashboardEvent{ .. contains different data class and object class } now I have a third module common. Which contains generic components so sometimes I have to pass AuthEvent or DashboardEvent fun GenericComponent(event: ClassName){ .. inside this function I want to use something like that event.sealed class (data class or object class) } Any suggestion for me so that, I pass generic type class object as a function parameter and based on that class, I am able to use its internal functions. issues i got : circulating dependencies => when i add auth module and dashboard module into common module gradle file. 2nd thing. i dont want to make multiple names parameters function because one common module function used in a different modules and in different classes. so each module can access common module which is working fine.
😶 1
j

Jonny

02/14/2023, 1:57 PM
It's not possible to have modules depend on each other, directly or indirectly by a circular dependency. The common module should probably not have dependencies on other modules in your project since it's meant to be used by any other module. It definitely shouldn't depend on the Dashboard module, which means that you can't use DashboardEvent in the common module. It could depend on the auth module if the auth module doesn't require any dependency on the common module. If it does, you may simply want to remove the auth module and put the auth code into the common module instead. You should think about which functions should go into the common module and if you need to move something. I don't know what the dashboard event is or what the function you're trying to call is supposed to do so it's hard for me to make any suggestions regarding which code should go where.
6 Views