title: How to initialize a remember value from an asynchronously provided argument?
body: <p>I want to initialize a <code>remember</code>ed <code>StateMap</code> from a <code>List</code> argument I'm getting passed to my Composable. After the initialization, I want to modify this list and remember the changes on recomposition (hence the <code>remember</code>). The problem is that this <code>List</code> is loaded from a Room database asynchronously, and on first composition, it's empty.
  The <code>expandedStates</code> <code>Map</code> never gets filled with values so I assume on recomposition the initialization block is not executed again.</p>
  <p>How do I initialize this StateMap correctly?</p>
  <pre><code>@Composable
  fun TodoList(
      todos: List&lt;Todo&gt;,
      [...]
  ) {
      // this map stays empty
      val expandedStates = remember {
          mutableStateMapOf&lt;Long, Boolean&gt;().apply {
              todos.map { todo -&gt;
                  todo.id to false
              }.toMap().also {
                  putAll(it)
              }
          }
      }
  
      [...]
  }
  </code></pre>