In my ViewModel I have such a code:
...
private val billingClientLifecycle: BillingClientLifecycle
private val _isBillingConnectionReady = MutableLiveData<Boolean>()
val isBillingConnectionReady: LiveData<Boolean> = _isBillingConnectionReady
...
init {
...
billingClientLifecycle.setPurchaseUpdateListener(
object : IapPurchasesUpdatedListener {
...
override fun isBillingConnected(state: Boolean) {
Log.i(TAG, "Billing connection state is: $state")
_isBillingConnectionReady.value = state
}
}
)
billingClientLifecycle.createBillingConnection(getApplication())
...
}
...
So here I have a billingClientLifecycle
object and in init()
I invoke createBillingConnection
method I see that I get a response in the callback isBillingConnected
and I see that _isBillingConnectionReady
livedata is being called, however, I don't get this event in my fragment where I subscribed on this event.
What am I missing here? Why live data doesn't pass the event? Could it be somehow because the callback captures the values?