Hi, can i convert this Firebase Phone Auth code to...
# coroutines
Hi, can i convert this Firebase Phone Auth code to coroutines friendly, in below method i have two options first is that i can scope this call to activity and second is that i can add some Executor(which i don't know how works). but here i don't want this request to be scoped on Activity because i don't want this request inside Activity instead i want to move it inside ViewModel or Repository.
Copy code
number, 1, TimeUnit.MINUTES,
executor or Activity // but here i don't wanna scope it to activity instead i want to use it inside ViewModel using coroutines
You can create an executor that dispatches to a coroutine dispatcher.
@louiscad do you have any docs about it or any sample code, because i did not worked with executors
You'll also need
to wrap the callback. @Kulwinder Singh If it's still "not working", please specific about what doesn't work exactly and what you tried.
I thought about it but what should i use at place of
parameter those are not nullable
is interface, look. You can implement it and pass the runnables to a coroutine dispatcher.
as usual terrible API from Firebase Attempt to make thing easier for “common developer” ™ makes thinks awkward for real developers
it even doesn’t follow other similar APIs from Google, which usually use Handler to deliver result
anyway, use Executor is right solution in this case, just implement it (as i see, it even may be empty, no need to dispatch)