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

Add tag argument to Screen.getScreenModel #101

Merged
merged 3 commits into from Mar 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -14,9 +14,11 @@ import dagger.hilt.android.EntryPointAccessors
* @return A new instance of [ScreenModel] or the same instance remembered by the composition
*/
@Composable
public inline fun <reified T : ScreenModel> Screen.getScreenModel(): T {
public inline fun <reified T : ScreenModel> Screen.getScreenModel(
tag: String? = null
): T {
val context = LocalContext.current
return rememberScreenModel {
return rememberScreenModel(tag) {
val screenModels = EntryPointAccessors
.fromActivity(context.componentActivity, ScreenModelEntryPoint::class.java)
.screenModels()
Expand All @@ -38,10 +40,11 @@ public inline fun <reified T : ScreenModel> Screen.getScreenModel(): T {
*/
@Composable
public inline fun <reified T : ScreenModel, reified F : ScreenModelFactory> Screen.getScreenModel(
tag: String? = null,
noinline factory: (F) -> T
): T {
val context = LocalContext.current
return rememberScreenModel {
return rememberScreenModel(tag) {
val screenFactories = EntryPointAccessors
.fromActivity(context.componentActivity, ScreenModelEntryPoint::class.java)
.screenModelFactories()
Expand Down