Is there a way to grab the NavController like a si...
# compose
j
Is there a way to grab the NavController like a singleton? I have an async api call that I want to switch screens if returned ok. Right now I have to physically pass the nav controller into the async cb and it would be alot cleaner if I could call it back as a singleton when ever I needed it in my code.
a
Passing nav controller isn't the recommended way since it makes your code difficult to test. Passing lambdas is easier to test
1
j
Yes, please don't pass down the NavController. Elaborate explanation here: https://medium.com/google-developer-experts/navigating-in-jetpack-compose-78c78d365c6a
👍 1
1