Skip to content

How to track compose screens #696

Answered by arkivanov
Foenix00001 asked this question in Q&A
Discussion options

You must be logged in to vote

You can observe navigation state changes as follows:

class DefaultRootComponent(
    componentContext: ComponentContext,
) : RootComponent, ComponentContext by componentContext {
    private val navigation = StackNavigation<Config>()

    private val _stack =
        childStack(
            source = navigation,
            serializer = Config.serializer(),
            initialStack = ...,
            childFactory = ::child,
        )

    override val stack: Value<ChildStack<*, Child>> = _stack

    init {
        var lastActiveConfig: Config? = null
        _stack.subscribe {
            val activeConfig = it.active.configuration
            if (activeConfig != lastActiveConfig) {
       …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Foenix00001
Comment options

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