Skip to content

Routing between screens elegantly? #56

Answered by plusmobileapps
ScottPierce asked this question in Q&A
Discussion options

You must be logged in to vote

I will work off your initial example assuming this is what lives in your RootComponentImpl with the addition of a main screen.

sealed class Screen : Parcelable {
    @Parcelize
    object AppLoading : Screen()
    object Main : Screen() 
    // ...
}

So normally in the RootComponent I create a child class which will take the needed component as a parameter.

    sealed class Child  {
        object AppLoading : Child() 

        data class Main(
            val mainComponent: MainComponent
        ) : Child()
    }

Your router would then need to add the child as the second parameter to the router type

    private val router: Router<Screen, RootComponent.Child> = router(
        initialConf…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
2 replies
@ScottPierce
Comment options

@plusmobileapps
Comment options

Answer selected by ScottPierce
Comment options

You must be logged in to vote
4 replies
@ScottPierce
Comment options

@ScottPierce
Comment options

@plusmobileapps
Comment options

@arkivanov
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants