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

Jeisson Sáchica

11/19/2020, 9:19 PM
Hello guys! I was wondering what is the best wat to pass data into composition? Let's say in my MainActivity I call another activity and get some data in the onActivityResult, how do I go about passing this data into my composition tree? I was thinking I could have an activity view model with a LiveData and do observeAsState inside, but I don't know if that is the best way
l

Leland Richardson [G]

11/19/2020, 9:50 PM
yeah i think just a plain old MutableState would be how i’d do this, but might depend on use case
j

Jeisson Sáchica

11/19/2020, 9:53 PM
Oh wait, MutableState is not compose specific? I can just have one in my activity and update it wheneve I want to trigger recomposition?
👌 3
🤯
Thanks I was totally missing that part
i

Ian Lake

11/20/2020, 12:07 AM
We've talked about Activity Results a couple of times in the past - https://issuetracker.google.com/172690553 tracks making it easy to use the Activity Result API from Compose (but links to the code you can use right now)
j

Jeisson Sáchica

11/20/2020, 12:47 AM
Great thanks Ian! I'll checkout the links that are there thank you