Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass repository as parameter to ViewModel #407

Open
alirezaeiii opened this issue Jan 12, 2025 · 0 comments
Open

Pass repository as parameter to ViewModel #407

alirezaeiii opened this issue Jan 12, 2025 · 0 comments

Comments

@alirezaeiii
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant