title: How to call Kotlin coroutine in composable function callbacks?
body: <p>I want to call a suspend-function inside of a callback of composable-function.</p>
  <pre class="lang-kotlin prettyprint-override"><code>suspend fun getLocation(): Location? { /* ... */ }
  
  @Composable
  fun F() {
  
      val (location, setLocation) = remember { mutableStateOf&lt;Location?&gt;(null) }
  
      val getLocationOnClick: () -&gt; Unit = {
          /* setLocation __MAGIC__ getLocation */
      }
  
      Button(onClick = getLocationOnClick) {
          Text(&quot;detectLocation&quot;)
      }
  
  }
  </code></pre>
  <p>If I would have used Rx then I could just <code>subscribe</code>.</p>
  <p>I could do <code>invokeOnCompletion</code> and then <code>getCompleted</code>, but that API is experimental.</p>
  <p>I can't use <code>launchInComposition</code> in <code>getLocationOnClick</code> because <code>launchInComposition</code> is <code>@Composable</code> and <code>getLocationOnClick</code> can not be <code>@Composable</code>.</p>
  <p>What would be the best way to get result of a suspending function inside a regular function, inside <code>@Composable</code> function?</p>