title: Jetpack Compose pass parameter to viewModel
body: <p>How can we pass parameter to <code>viewModel</code> in <code>Jetpack Compose</code>?</p>
  <p>This is my composable</p>
  <pre><code>    @Composable
      fun UsersList() {
        val myViewModel: MyViewModel = viewModel(&quot;db2name&quot;) // pass param like this
      }
  
  </code></pre>
  <p>This is <code>viewModel</code></p>
  <pre><code>    class MyViewModel(private val dbname) : ViewModel() {
          private val users: MutableLiveData&lt;List&lt;User&gt;&gt; by lazy {
              MutableLiveData&lt;List&lt;User&gt;&gt;().also {
                  loadUsers()
              }
          }
      
          fun getUsers(): LiveData&lt;List&lt;User&gt;&gt; {
              return users
          }
      
          private fun loadUsers() {
              // Do an asynchronous operation to fetch users.
          }
      }
  </code></pre>