I assume you mean to say, you want to return after...
# android
s
I assume you mean to say, you want to return after
checkOrginization()
method after completing the loop in success listener. Am’I getting it right?
r
yes, right
s
That’s not possible, because when you call
checkOrganization()
that function is called immediately. In that function you are creating listener
addOnSuccessListener{}
, that will be called whenever there is a success. Or might never be called in the case of failure, you cannot keep
checkOrganization()
blocked until then.
r
yes I understand that. but I don't know how to solve it
s
Whatever action you want to do, after you have completed success listener, you can move it into a separate function. And you can call that function from
addOnSuccessListener{}
r
I will keep looking. thanks
s
If you have the scope to make this method suspended, you can use
suspendCancellableCoroutine
and resume the coroutine with success, whenever you want.
r
I created my own listener. I used to to it in Java
I need to learn about Co routines first
s
Glad to know you worked it out for yourself.
r
Thanks bro