Java doesn’t do coroutines, so the current Client implementation is sync. But Kotlin does, and we might benefit from a different async client. I think we can do it like this:
- Add an AsyncTask protocol that has an
suspend fun execute instead of the sync execute function.
- Create an AsyncClient class to use instead of Client.
suspend fun execute(client: AsyncClient, context: Context).
- When the task is executed, check which protocol is used. Wrap
runBlocking around the async task.
- Make the annotation processor detect
suspend fun so the same @Builder.Task can be used on both sync and async and automatically does the right thing.
The only question is whether we just add Async to both Task and Client. Should the sync version be renamed? (BlockingTask & BlockingClient?)
Java doesn’t do coroutines, so the current
Clientimplementation is sync. But Kotlin does, and we might benefit from a different async client. I think we can do it like this:suspend fun executeinstead of the sync execute function.suspend fun execute(client: AsyncClient, context: Context).runBlockingaround the async task.suspend funso the same@Builder.Taskcan be used on both sync and async and automatically does the right thing.The only question is whether we just add
Asyncto both Task and Client. Should the sync version be renamed? (BlockingTask & BlockingClient?)