Thread
#compose
    j

    Jason Inbody

    1 year ago
    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

    Abhishek Dewan

    1 year ago
    Passing nav controller isn't the recommended way since it makes your code difficult to test. Passing lambdas is easier to test
    jossiwolf

    jossiwolf

    1 year ago
    Yes, please don't pass down the NavController. Elaborate explanation here: https://medium.com/google-developer-experts/navigating-in-jetpack-compose-78c78d365c6a