https://kotlinlang.org logo
#coroutines
Title
# coroutines
a

Alexey Pushkarev

12/08/2018, 10:02 PM
Hi, folks. I've just wrapped android billing into coroutines https://github.com/lion4ik/BillingCoroutines . I would appreciate your code review. Feel free to come up with ideas and issues. 🙂
b

bdawg.io

12/08/2018, 10:53 PM
Using a
sealed class
for your various
BillingException
types seem like a win. It in general makes your exceptions nicer to consume via
try..catch
or
is
For example, using
BillingServiceDisconnectedException
that extends
sealed class BillingException
inside your
suspend fun connectService()
instead of
BillingException(BillingClient.BillingResponse.SERVICE_DISCONNECTED)
https://github.com/lion4ik/BillingCoroutines/blob/c6351b72019e80a67c8665d895752ec652699c34/billing/src/main/java/com/github/lion4ik/billing/BillingManager.kt#L54
It looks like you already have made the various exceptions, but not using your
BillingExceptionFactory
in your
suspend fun connectService()
I would definitely recommend making
BillingException
a
sealed class
instead of just an
open class
d

Dico

12/09/2018, 12:26 AM
Also move all those exceptions to the same file. They're all one liners and they're all exceptions.
👍🏾 1
a

Alexey Pushkarev

12/09/2018, 11:53 AM
thanks @bdawg.io! Make sense, I will definitely fix it!
13 Views