decompose-router 0.5.1 Help

How to Use Decompose Router

Decompose router supports the following navigation models, that is driven by a model

  1. Stack navigation

  2. Page navigation

  3. Slot navigation

These are the same ones supported by Decompose

Stack navigation

Stack is a navigation model for managing a stack of components

Slot navigation

Slot is a navigation model that allows only one child component at a time, or none.

Page navigation

Pages is a navigation model for managing a list of components (pages) with one selected (active) component.

Model driven navigation

Model driven navigation is the idea that each node of your navigation hierarchy is represented by a model with a strict schema (as opposed to a URL string). This strict schema makes all the navigation arguments type-safe

For example, a typical list/detail screen flow would look like this

@Serializable sealed class Screens { @Serializable data object List: Screens() @Serializable data class Details(val number: Int): Screens() }

Another example, collection of pages

@Serializable enum class Pages { Page1, Page2, Page3 }

Or if your navigation graph is just a single page, it can even be a single object

@Serializable object Screen
Last modified: 25 November 2024