title: How to transform an Android Task to a Kotlin Deferred?
body: <p>Firebase anonymous sign in returns a <a href="https://developers.google.com/android/guides/tasks" rel="noreferrer">task</a> (which is basically <a href="https://en.wikipedia.org/wiki/Futures_and_promises" rel="noreferrer">Google promise implementation</a>):</p>
  
  <pre><code>val task:Task&lt;AuthResult&gt; = FirebaseAuth.getInstance().signInAnonymously()
  </code></pre>
  
  <p>How it would be possible create a <code>signInAnonymous</code> wrapper where:</p>
  
  <ul>
  <li><p>It is a <code>suspend</code> function, waiting for the <code>task</code> completion</p>
  
  <ul>
  <li><code>suspend fun signInAnonymous(): Unit</code></li>
  </ul></li>
  <li><p>It returns a <code>Deferred</code> object, delivering the result asynchronously </p>
  
  <ul>
  <li><code>fun signInAnonymous() : Deferred</code></li>
  </ul></li>
  </ul>