https://kotlinlang.org logo
#compose
Title
# compose
n

Nat Strangerweather

01/08/2021, 10:23 PM
I'm really confused about
.observeAsState
. In my ViewModel I have this:
Copy code
val dynamicCallSenderCode = MutableLiveData(0)

     fun onSenderChanged (){
        dynamicCallSenderCode.value = broadcastReceivers.notifyCallSenderCode(context)
    }
What I want to do is observe the broadcast receiver changes from my HomePage but I can't use
.observeAsState
with a function. How could I pass these changes live to my Composable?
i

Ian Lake

01/08/2021, 11:11 PM
What exactly do you mean? Seems like you'd be able to do
val senderCode = viewModel.dynamicCallSenderCode.observeAsState().value
and that would recompose anytime the value changes
👍 1