I am using the Play Services [Auth api Phone](https://developers.google.com/android/reference/com/google/android/gms/auth/api/phone/package-summary) and so far I have the foll 

```
  fun startSmsListener() {
    val client = SmsRetriever.getClient(applicationContext /* context */);
    val task = client.startSmsRetriever();
    task.addOnSuccessListener(object : OnSuccessListener<Void> {
        override fun onSuccess(p0: Void?) {
             //do somethin
        }

    })
    task.addOnFailureListener(object : OnFailureListener {
        override fun onFailure(p0: Exception) {
            //Handle error
        }

    })
}

```

Now I want to put this in an SmsManager class and convert it into an Single/Observable so I can handle it in a reactive way in my viewmodel. How can I do that?

So far I've got this:

```
var single = Single.create(SingleOnSubscribe<Void> { e ->
                val task = client.startSmsRetriever()
                task.addOnSuccessListener {
                    e.onSuccess(it)
                }
                task.addOnFailureListener {
                    e.onError(it)
                }
        })

```

But I am unsure as to whether this code is correct or not, whether there is something im missing like removing the listeners after disposal.

Any help?