Skip to content

1.0.0-alpha-03

Compare
Choose a tag to compare
@arkivanov arkivanov released this 22 Aug 09:08
· 952 commits to master since this release
b3d13f8
  • Compare configurations by equality in Child Stack (#182)

Bug fix

This release fixes a bug that existed for a long time. Now Child Stack compares configurations by equality and not by references. This avoids unnecessary component re-creations in some conditions.

Here is an example of affected use case:

class Root(componentContext: ComponentContext): ComponentContext by componentContext {
    private val navigation = StackNavigation<Config>()
    private val stack = childStack(source = navigation, initialConfiguration = Config.Tab1("1")) { ... }
    
    fun foo() {
        navigation.bringToFront(Config.Tab2("2"))

        // At this point the stack is: [1, 2].
        // Before this release, the call below caused re-creation of Tab1 component.
        // This is because configurations were compared by reference, instead of equality.
        // Re-creation happens only if the configuration is a class, singleton objects are not affected.
        navigation.bringToFront(Config.Tab1("1"))
    }
    
    private sealed interface Config : Parcelable {
        @Parcelize
        data class Tab1(val payload: String) : Config

        @Parcelize
        data class Tab2(val payload: String) : Config
    } 
}

Versions and dependencies

Kotlin: 1.7.0
Essenty: 0.5.2

extensions-compose-jetpack

Jetpack Compose: 1.2.0
Jetpack Compose Compiler: 1.2.0

extensions-compose-jetbrains

JetBrains Compose: 1.2.0-alpha01-dev753