How do I call a @Composable function from within L...
# android
e
How do I call a @Composable function from within LiveData's observe method?
a
You don't; a LiveData observer is an imperative event callback and a
@Composable
function is declarative. LiveData observers are about applying changes when data changes occur, but a Compose composition is already an engine for doing this. Check out the
LiveData.observeAsState
extension function; you can call it from inside of a
@Composable
instead of manually adding observers to the LiveData.
e
Is there anywhere else to look up api references, developer.android.com is taking forever with its searches
a
that's the source of truth for the docs. Where are you searching from? curious what might be going on if search there is taking a while
e
Top of the page, tried looking manually in the api reference page and couldn't find it. Found this article though https://luboganev.dev/post/observe-as-state-is-the-new-postvalue/
a
The search at the top of the page shows me this for the search query observeAsState:
are you seeing something different?
e
I'm seeing it just spinning
a
hm, interesting. Any extensions? It comes back pretty quick for me using chrome or firefox, uBlock origin, privacy badger active
(curious if there's anything interesting to report to our docs team here)
e
The only shared extension between (its Firefox browser) the browers on my phone and desktop is uBlock
It maybe because I live behind a vpn constantly?
Now its instant