-
-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1809 from InsertKoinIO/fix/viewmodel_key_scope
Fix ViewModel key generation + Fix ViewModel scope handling
- Loading branch information
Showing
17 changed files
with
230 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
...roidx-samples/src/main/java/org/koin/sample/sandbox/components/mvvm/ExtSimpleViewModel.kt
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
...ndroidx-samples/src/main/java/org/koin/sample/sandbox/components/mvvm/MyScopeViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.koin.sample.sandbox.components.mvvm | ||
|
||
import androidx.lifecycle.ViewModel | ||
import org.koin.core.component.KoinScopeComponent | ||
import org.koin.core.component.createScope | ||
import org.koin.core.scope.Scope | ||
import org.koin.sample.sandbox.components.scope.Session | ||
|
||
class MyScopeViewModel : ViewModel(), KoinScopeComponent { | ||
|
||
override val scope: Scope = createScope(this) | ||
|
||
val session by scope.inject<Session>() | ||
|
||
override fun onCleared() { | ||
super.onCleared() | ||
scope.close() | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...droidx-samples/src/main/java/org/koin/sample/sandbox/components/mvvm/MyScopeViewModel2.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.koin.sample.sandbox.components.mvvm | ||
|
||
import org.koin.androidx.scope.ScopeViewModel | ||
import org.koin.core.annotation.KoinExperimentalAPI | ||
import org.koin.sample.sandbox.components.scope.Session | ||
|
||
@OptIn(KoinExperimentalAPI::class) | ||
class MyScopeViewModel2 : ScopeViewModel() { | ||
|
||
val session by scope.inject<Session>() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.