Skip to content

Commit

Permalink
add a screen model definition
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottPierce committed Jul 17, 2024
1 parent 389be3d commit 9f9b29f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package kinject.compose.voyager

import cafe.adriel.voyager.core.model.ScreenModel
import kinject.ObjectGraph

/**
* A ScreenModel representation that delegates to factory.
*/
inline fun <reified SM : ScreenModel> ObjectGraph.Builder.screenModel(
noinline provider: ObjectGraph.() -> SM,
): Unit = factory(SM::class, provider)
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import androidx.lifecycle.ViewModel
import kinject.ObjectGraph

/**
* A ViewModel representation that delegates to
* A ViewModel representation that delegates to factory.
*/
inline fun <reified T : ViewModel> ObjectGraph.Builder.viewModel(
noinline provider: ObjectGraph.() -> T,
): Unit = factory(T::class, provider)
inline fun <reified VM : ViewModel> ObjectGraph.Builder.viewModel(
noinline provider: ObjectGraph.() -> VM,
): Unit = factory(VM::class, provider)

0 comments on commit 9f9b29f

Please sign in to comment.