Skip to content

Pass repository as parameter to ViewModel #407

Open
@alirezaeiii

Description

@alirezaeiii

Hi, I was looking at your ViewModel by using the KoinComponent to inject the repository, so in iOS you will not have to pass any parameter to ViewModel for initialization.

I have another workaround for this which makes it possible to pass a repository as a parameter using the KoinPlatform :

https://github.com/alirezaeiii/TMDb-KMM/blob/main/shared/src/commonMain/kotlin/org/example/tmdb/di/Koin.kt

So in iOS you can init ViewModel using the above helper function using KoinKt.getViewModel() :

https://github.com/alirezaeiii/TMDb-KMM/blob/main/iosApp/iosApp/ContentView.swift

Do you think which approach is preferable and why? Since you have extensive experience in KMM.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions