Skip to content

Sealed state structures vs. navigation children #449

@sergejsha

Description

@sergejsha

This is a call for discussion and opinion exchange.

While implementing screens with a sealed state structure like

sealed interface State {
    data object Loading : State
    data class Content(val userName: String, val userEmail: String) : State
}

I realized that the state holds a navigation aspect in it - Loading represents one child and Content another one. The difference to the conventional navigation is that the navigation path is represented by the state and is dispatched to view as a state.

An alternative to it would be to define two navigation children, one per a sealed sub-type, and declare a flat data class state for content.

@arkivanov Do you have any opinion or thoughts on this? Are there any best practices for such sealed states?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions