https://kotlinlang.org logo
Join SlackCommunities
Powered by
# decompose
  • b

    benkuly

    12/04/2024, 12:37 PM
    What is the reason, that the lifecycle of a child component must not be destroyed? https://arkivanov.github.io/Decompose/component/child-components/ Our use case: We have an infinite list (messenger timeline), where elements are created and removed when scrolling up and down. Each element view model uses a childContext of the timeline. We pass a lifecycle to destory it, when the element is remove from the list. Now we get
    The lifecycle of a child ComponentContext must never be destroyed manually.
    a
    • 2
    • 13
  • a

    Arkadii Ivanov

    12/08/2024, 5:13 PM
    Decompose
    3.3.0-alpha01
    is released! ๐Ÿ‘‰ Added the new Web Navigation API with nested navigation support ๐Ÿ‘‰ Added placeholders for
    ChildPanels
    composable function ๐Ÿ‘‰ Use
    Nothing
    type for
    ChildPanels
    composable function without Extra panel ๐Ÿ‘‰ Fixed a crash when multiple retained components are created with different keys Release notes: https://github.com/arkivanov/Decompose/releases/tag/3.3.0-alpha01
    ๐Ÿ‘ 2
    ๐Ÿ™Œ 1
  • v

    Vaibhav Jaiswal

    12/10/2024, 3:10 PM
    @Arkadii Ivanov I am facing this weird error when navigating
    Copy code
    Expected to be called on the main thread, but was DefaultDispatcher-worker-2
    com.arkivanov.decompose.mainthread.NotOnMainThreadException: Expected to be called on the main thread, but was DefaultDispatcher-worker-2
    Even though im not calling navigate from any coroutine I even tried adding this
    launch(Dispatchers.Main)
    intentionally, but i still get this error
    Copy code
    private fun navigate(
        screen: ScreenConfig,
        replace: Boolean = false,
        replaceAll: Boolean = false
    ) = rootComponent.scope.launch(Dispatchers.Main){
        when {
            replaceAll -> navigator.replaceAll(screen)
            replace -> navigator.navigate {
                it.dropLast(1) - screen + screen
            }
            else -> navigator.pushToFront(screen)
        }
    }
  • a

    Arkadii Ivanov

    12/10/2024, 3:20 PM
    The error is printed in the logs when you navigate or init your navigation on a non-main thread. There should be a stack trace pointing to the offending code.
    v
    • 2
    • 11
  • a

    Arkadii Ivanov

    12/13/2024, 10:20 PM
    Decompose
    3.3.0-alpha02
    is released! ๐Ÿ‘‰ Added
    isPredictiveBack
    flag to the experimental`stackAnimation` function with selector Release notes: https://github.com/arkivanov/Decompose/releases/tag/3.3.0-alpha02
    ๐Ÿ‘ 3
  • o

    Ozerov Max

    12/24/2024, 5:32 AM
    Hello, @Arkadii Ivanov, I'm currently making an app for iOs and I'm trying to use Predictive Back Gesture implementation from the documentation, which implements the Cupertino back swipe. But I ran into the following problem: if there is an element with horizontal scrolling on the screen (LazyRow for example), it stops scrolling normally because
    Modifier.handleBackGestures
    from
    PredictiveBackGestureOverlay
    is prioritized. Any ideas how to fix it?
    u
    a
    • 3
    • 18
  • v

    Vaibhav Jaiswal

    12/28/2024, 5:04 AM
    @Arkadii Ivanov I have a childStack and in the first screen i have a bottom nav using childStack One back button press how can i move to a specific bottom nav tab and on next back press, close the app I tried using
    BackCallback
    but, it lands me back to that tab on back press, but on next back press it does not close the app I'm using
    navigator.pop()
    for this
    a
    • 2
    • 3
  • a

    Adam Brown

    12/30/2024, 2:05 AM
    All roads lead back to @Arkadii Ivanov ๐Ÿ˜‚ https://github.com/gradle/gradle/issues/26091
    ๐Ÿ˜ 1
  • a

    Arkadii Ivanov

    01/12/2025, 11:09 AM
    Decompose
    3.3.0-alpha03
    is released! ๐Ÿ‘‰ Updated Kotlin to
    2.1.0
    , Essenty to
    2.4.0
    , AGP to
    8.7.3
    , Gradle to
    8.11.1
    ๐Ÿ‘‰ Added
    AnimatedVisibilityScope
    to
    ChildPanels
    content composables ๐Ÿ‘‰ Updated Essenty to
    2.5.0-alpha01
    Release notes: https://github.com/arkivanov/Decompose/releases/tag/3.3.0-alpha03
    K 4
  • c

    CXwudi

    01/19/2025, 6:48 PM
    Hi, is it possible to use
    childPanels()
    navigation model and the
    ListDetailPaneScaffold()
    together instead of the
    ChildPanels()
    composable? It looks like the navigation models are so different that it doesn't seems to be possible. Maybe the only solution to use
    ListDetailPaneScaffold()
    with Decompose is to just call
    childContent()
    but not
    childPanels()
    ?
    a
    • 2
    • 2
  • r

    Rafael Costa

    02/03/2025, 12:20 PM
    Hi! Say that on a given component, I have a child slot. I want to expose a single
    uiState
    flow to my UI. As part of that UI State, if child slot is active, I want to provide the child instance, if it is not active I want to provide some other state data class. The way I see it, to do this, I would combine the
    Value<ChildSlot<X, Y>>
    with some other internal state flow. Question is: can I convert the
    Value
    into a StateFlow to allow me to combine it? Or is there any consequence of doing so, such as performance considerations or the like? I have a snippet that I think came from you @Arkadii Ivanov to do that conversion, I can paste on the thread.
    a
    • 2
    • 7
  • d

    Djuro

    02/05/2025, 9:22 AM
    Hello everyone. Using Decompose in a Compose multiplatform project. On iPhones they usually go back by swiping on the screen instead of using back arrows. Is there a possibility to enable going back on swipe for iPhones?
    a
    • 2
    • 2
  • a

    Arkadii Ivanov

    02/09/2025, 8:28 PM
    Decompose
    3.3.0-beta01
    is released! - Updated Essenty to
    2.5.0-beta01
    Release notes: https://github.com/arkivanov/Decompose/releases/tag/3.3.0-beta01
    decompose intensifies 2
    K 3
  • a

    Adi Trioka

    02/14/2025, 1:50 AM
    Hi everyone. I just tried using Decompose for navigation in my multiplatform project, and Iโ€™m a bit confused. I just watched Arkadiiโ€™s video here:

    https://youtu.be/FFO_4NNDUoU?si=6rKtIEiKv4egRJ59&amp;t=423โ–พ

    . My question is, for nested navigation like this, do we need to create a screen for each parent component? For example, here we have the Signed Out and Signed In components. Do we need to create a composable SignedOutScreen and SignedInScreen as the parent composable for the child components/composables underneath?
    a
    • 2
    • 2
  • p

    Philip Dukhov

    02/20/2025, 5:31 AM
    Hey! I was wondering if
    StateKeeper
    `consume`/`register` methods could use the same technique (or have an overload) that
    Json.encodeToString
    does, so we don't have to pass the serializer manually, with something like
    essentyJson.serializersModule.serializer()
    ? I think I can use
    Json
    instead of
    essentyJson
    and do an extension on my end, as the lib doesn't and is not expected to modify the
    serializersModule
    in the future, but it would be nicer to be shipped with the lib.
    a
    • 2
    • 2
  • a

    Andrey Larionov

    02/25/2025, 1:46 PM
    Hi guys and @Arkadii Ivanov, I have a question Let's say each
    BottomNavigation
    tab (
    ExploreRootScreen
    ,
    WalletRootScreen
    and
    ProfileRootScreen
    ) has it's own
    ChildStack
    Copy code
    @Composable
    internal fun HomeRootScreen(component: HomeRootComponent) = Box(
        modifier = Modifier.fillMaxSize()
    ) {
        StackContent(component)
        BottomNavigation(component)
    }
    
    @Composable
    private fun StackContent(component: HomeRootComponent) {
        val homeStack by component.stackRouter.subscribeAsState()
        Children(
            // ...
            content = { childStack -> childStack.instance.getContentByChild() }
        )
    }
    
    @Composable
    private fun HomeRootChild.getContentByChild() = when (this) {
        // ...
        is ProfileRootChild -> ProfileRootScreen(this) // with ProfileRootComponent
    }
    BottomNavigation
    is drawn over
    StackContent
    using
    Alignment.Bottom
    If we need to display a Dialog (
    ChildSlot
    ) somewhere deep inside of tab's
    ChildStack
    , it should be drawn above
    BottomNavigation
    I created a diagram where
    LogoutDialog
    and
    SwitchLanguageDialog
    (marked with yellow color) should appear. Each child in the diagram (marked with blue, yellow and pink colors) has it's own
    ChildComponent
    (e.g,
    LanguageComponent
    and
    SwitchLanguageComponent
    ) And as I understand Decompose, for
    SwitchLanguageDialog
    I should create
    ChildSlot
    inside
    LanguageComponent
    and this Dialog should be displayed on
    LanguageScreen
    That's ok, but it will be drawn under the BottomNavigation I assume I could create
    ChildSlot
    at
    HomeRootComponent
    level, but โ€ข I'm not sure how to handle different children from different nested screens (e.g, using
    activeSlotChild: Flow<BaseSlotChild>
    seems odd due to a large
    when
    check) โ€ข I don't know if this approach would break children back navigation (e.g, when Dialog is displayed, using system back swipe might trigger
    ChildStack
    's backHandler) How should I handle this properly? Thanks in advance
    a
    • 2
    • 2
  • a

    Andrey Larionov

    02/25/2025, 1:46 PM
    CleanShot 2025-02-25 at 17.46.27.jpg
  • a

    Arkadii Ivanov

    02/25/2025, 4:30 PM
    Decompose
    3.3.0
    is released! Release notes: https://github.com/arkivanov/Decompose/releases/tag/3.3.0
    โ™ฅ๏ธ 2
    ๐ŸŽ‰ 7
  • p

    Philip Dukhov

    03/12/2025, 6:11 AM
    I'd like to set up navigation state logging for Sentry. One of the problems is that I can't think of a way to log the navigation tree - I have a deep tree of nested components. It may be enough to just log the stack being updated, perfectly it would be nice to name the action, like push/pop/pushNew, it could have been done with comparing old/new count, but may not be accurate with replacing multiple items. Another issue is that I often store a model object in the config, and in the log I would only want to include limited info about the object, like object id. Feels like I would need to parse strings manually, as Kotlin serialization is not flexible enough to allow me to override the serialization logic for each object of a specific interface. Any chance someone has already worked on something like this?
    a
    a
    • 3
    • 3
  • p

    Philip Dukhov

    03/12/2025, 2:08 PM
    Just wanted to say thanks for the library โ€” my application architecture is much cleaner now, which has taken away a lot of stress and negative emotions, and Iโ€™m genuinely enjoying programming again ๐Ÿ˜Š
    decompose intensifies 12
  • p

    Philip Dukhov

    03/24/2025, 5:57 AM
    In the release build with R8 I've got a crash from
    typeOf
    related to generic type
    Copy code
    data class InstanceToRetain<T>(val value: T)
    
    retainedSimpleInstance { InstanceToRetain(0) }
    Looks like it's something you've faced already, what do you think is the best workaround here? For now I switched to
    T::class
    , it obviously loses nested
    T
    info, but at least it would crash in debug app version if I try to use the same key somewhere, so it's easier to catch during development.
    a
    • 2
    • 1
  • s

    sasikanth

    03/26/2025, 4:24 AM
    Anyone used ChildPages with AndroidX Paging before? Is that at all possible? there is only List param when creating the initial pages, so just want to check to see if I am missing something. ๐Ÿค”
    a
    v
    • 3
    • 4
  • v

    Vaibhav Jaiswal

    04/05/2025, 1:37 PM
    @Arkadii Ivanov I want to track ScreenName for Analytics purpose, I have a 3 layer nested Navigation hierarchy So Root Level Screens, it has a HomeScreen which has bottom navigation, and then each bottom nav tab has a Pager in it. How would you suggest achieving ScreenName tracking in such a multi layer nav structure ? One way I could think of is listening to the activeItem changes in childPages and childStack, but will that handle proper name change when a back navigation happens in a layer above.
    a
    • 2
    • 8
  • c

    Can

    04/09/2025, 9:15 AM
    Hey. Weโ€™ve come across an unexpected behavior in an edge case. Weโ€™re using a bottom bar, and clicking on the tabs triggers the
    bringToFront
    function in RootComponent. If the userโ€”_for some mysterious reason_โ€”starts rapidly switching between tabs, the navigation can get stuck on one of the screens. When that happens, the screen becomes unresponsive to clicks. We share the RootComponent in android and iOS and it affects both. I also noticed the same issue in the sample Decompose app.
    1.mp4
    a
    • 2
    • 5
  • a

    Andrey Larionov

    04/09/2025, 6:07 PM
    Hi I've faced the problem with predictive back navigation It worked great on Android and on iOS emulator, but it didn't work on real iPhone device And I found out that was because Compose
    1.8.0-beta01
    When I changed it with
    1.7.3
    ---> ๐Ÿ‘
    ๐Ÿ‘ 2
    d
    • 2
    • 1
  • a

    Andrew Steinmetz

    04/20/2025, 8:27 PM
    I know decompose comes with dependency injection out of the box, but as my projects were growing I switched over to kotlin-inject and kotlin-inject-anvil and was getting tired of writing a bunch of boiler plate code for the binding assisted factory interfaces similar to dagger. Since decompose heavily relies on assisted injection of the
    ComponentContext
    , I wrote a library that extends kotlin-inject-anvil to help bind and generate the assisted factory interface glue code to bind it in the kotlin-inject dependency graph that I thought others who use the library might be interested in. https://plusmobileapps.com/blog/2025/04/04/kotlin-inject-anvil-extensions/
    ๐Ÿ™Œ 1
    ๐Ÿ‘ 1
    a
    c
    • 3
    • 4
  • v

    Vaibhav Jaiswal

    05/01/2025, 11:20 AM
    @Arkadii Ivanov I have this usecase I need to call a suspend function in my RootComponent, but i want this to be called before the ChildStack Components are created This function call clears my Room DB, what i have done now is call it inside the
    doOnCreate
    but i am facing a bug that it sometimes completes after the ChildComponent is created, which then crashes as the app as db goes empty I want it to complete first (success or failure), then the ChildStack child components to be created
    a
    • 2
    • 1
  • v

    Vaibhav Jaiswal

    05/01/2025, 2:32 PM
    @Arkadii Ivanov is there a way to perform something when the predictive back nav is cancelled ? I have achieved it like this, it works, but is it correct ? Code in thread
    a
    • 2
    • 2
  • g

    Guyaume Tremblay

    05/01/2025, 8:30 PM
    @Arkadii Ivanov Following on my post in #CJLTWPH7S, I used Decompose already but I wondering if it could work with Compose Adaptive Layout ? I saw the new Child Panels but is it possible to use eg
    ListDetailPaneScaffold
    with ?
    a
    a
    • 3
    • 7
  • a

    Arkadii Ivanov

    05/03/2025, 12:33 AM
    Decompose
    3.4.0-alpha01
    is released! ๐Ÿ‘‰ Use SPDX identifier in POMs ๐Ÿ‘‰ Relax
    StrictMode
    with restarting the Activity stack for deep links ๐Ÿ‘‰ Don't restart Activity stack when there is no deep link ๐Ÿ‘‰ Added
    backHandlerPriority
    argument to
    childContext
    extension function ๐Ÿ‘‰ Updated Compose to
    1.8.0-rc01
    and
    compileSdkVersion
    to 35 Release notes: https://github.com/arkivanov/Decompose/releases/tag/3.4.0-alpha01
    K 5
    decompose intensifies 2