title: How to change AppBar Menu in Jetpack Compose?
body: <p>I was wondering how to change Appbar Menu in <code>Jetpack Compose</code>.</p>
  <p>In the <code>Fragment</code> world to achieve this is to do something like this:</p>
  <pre><code>class SampleFragment : Fragment() {
      override fun onCreate(context: Context) {
          super.onCreate(context)
          setHasOptionsMenu(true)
      }
  
      // Set the R.menu.sampleMenu in the AppBar
      override fun onCreateOptionsMenu(menu: Menu) {
          ...
          menuInflater.inflate(R.menu.sampleMenu, menu)
      }
  
      // To handle clicks on the menu
      override fun onOptionsItemSelected(item: MenuItem): Boolean {
          // Check id of menu item and process as follow
      }
  ...
  }
  </code></pre>
  <p>I was wondering how to do the exact same thing in Compose. I was thinking of having like:</p>
  <pre><code>// Have a top level state which could be set 
  var menu by remember { mutableStateOf(emptyList&lt;Menu&gt;()) }
  
  ....
  TopAppBar {
      ....
      menu.forEach {
          TextButton(...)
      }
  }
  
  ....
  
  //and then on my content ill set the `menu` to a value
  onCommit {
      menu = listOf(Menu1, Menu2, Menu3, ...)
  }
  </code></pre>
  <p>I was wondering whether this is the right way to do this or whether there is a better way.</p>
  <p>I would love to have some inputs and advice thank you very much.</p>