Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@SalomonBrys
Copy link
Member

Introduces new new functions that allow to define multiple arguments instead of pulling them from the container.

Compared to the parameterized new functions, these functions:

  • Allow to pass multiple arguments.
  • Because they are assigned by position, these functions do not use reflection and parameter types are resolved at compile time.

Usage example:

class ProfileViewModel(
    val userId: Uuid,
    val localDatabase: LocalDatabase,
    val apiClient: APIClient,
) : ViewModel() {
    // ...
}

@Composable
fun ProfileView(
    val userId: Uuid,
) {
    val di = localDI().direct
    // localDatabase & apiClient will be automatically set to di.instance()
    val vm = viewModel() { di.new(::ProfileViewModel, a1 = userId) }
}

@SalomonBrys SalomonBrys merged commit 86d5b28 into main Nov 20, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

3 participants