title: Wait for result from multiple callbacks/lambdas in Kotlin
body: <p>I'm making an app in Kotlin. Up until this point, my networking calls didn't have to be used together. I am now in a spot where I need to make two concurrent networking calls, pause until I receive both of their responses, and then continue execution. I'm trying to accomplish something like this:</p>
  
  <pre><code>    //first networking call, get resourceOne
      var resourceOne : String?
      Server.asyncRequest(RequestBuilder(endpoints.second, ids, params)) { resource: String?, error: ServiceError? -&gt;
          resourceOne = resource
      }
  
      //second networking call, get resourceTwo
      var resourceTwo : String?
      Server.asyncRequest(RequestBuilder(endpoints.third, ids, params)) { resource: String?, error: ServiceError? -&gt;
          resourceTwo = resource
      }
  
      //do something here wiith resourceOne and resourceTwo
  </code></pre>
  
  <p>The function header for my asyncRequest function is:</p>
  
  <pre><code>fun asyncRequest(requestBuilder: RequestBuilder, completion: (resource: String?, error: ServiceError?) -&gt; Unit) {
  </code></pre>
  
  <p>It just wraps around an okhttp request and does some extra processing/parsing. Normally I would just take the result (resource) and process it inside of the completion lambda, but since I need both values, I can't do that here. I've tried doing something similar to <a href="https://kotlinlang.org/docs/reference/coroutines/composing-suspending-functions.html#concurrent-using-async" rel="noreferrer">this</a> but my asyncRequest function does not have a return type, so I have no way of doing the async/await the way the link does.</p>