<@UHAJKUSTU> How can I have a feature like I have ...
# decompose
v
@Arkadii Ivanov How can I have a feature like I have an interface say
AuthComponent
and from androidMain, i provide a few components in a List and the same from iOSMain Like
List<AuthComponent>
And show all of them in a list inside a Component say
LoginComponent
, in this we inject the authComponents using Koin and display all How can I achieve this? I went through SlotNavigation, but does not seem it can work with a list of components UseCase: All Login buttons are a Decompose component, injected from androidMain and iosMain
a
Do I understand it correctly - you have a number of login buttons, and on a button click you need to show the corresponding AuthComponent with platform-specific implementation?
v
yes, and also platforms will have separate login buttons Example- Android will have Google, OTP iOS - Apple and Email Kind of
Not exactly, Each button is an AuthComponent And all buttons are displayed at the same time on click button wlill call some function of
AuthComponent
which starts the login flow
a
Got it! In this case, since the set of Auth components is also platform-specific, you can do something like this.
Copy code
class LoginComponent(
    componentContext: ComponentContext,
    authComponentsFactory: AuthComponentsFactory,
) : ComponentContext by componentContext {
    val authComponents: List<AuthComponent> = 
        authComponentsFactory { key -> childContext(key = key) }
}

fun interface AuthComponentsFactory {
    operator fun invoke(ctx: (key: String) -> ComponentContext): List<AuthComponent>
}
v
So this can be used like this to pass context to koin for instance creation of the components?
Copy code
get<List<AuthComponents>> { parametersOf(ctx("some key") }
Keys need to be unique for each AuthComponent ?
a
Something like that, but I'm not quite familiar with Koin. Keys must be unique for each component, so they should be provided by the implementation.
v
Understood, thanks Will give this a try and let you know if I face any issues
👍 1