https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
decompose
  • m

    Marko Novina

    11/10/2022, 6:54 AM
    Hello! Anyone faced issue like this? I’m just starting to use decompose so it might be that I’m doing something wrong. I get this error when I try to build Android app, but iOS app builds and runs with same code in shared module.
    e: /***/shared/src/commonMain/kotlin/*/*/*/root/RootComponent.kt: (38, 10): This class does not have a constructor
    Line that reports is where I use
    @Parcelize
    annotation. I use latest version of decompose: 1.0.0-alpha-07-native-compose. I will share code in 🧵 ⬇️
    a
    • 2
    • 8
  • t

    Tadeas Kriz

    11/11/2022, 6:54 PM
    Hey everyone! What's the recommended way of doing dynamic number of child components? Say I have a grid, that grid is one component, but then each item would be a separate component.
    childContext
    requires a key
    String
    which I don't have. Also the number of items in the grid is dynamic, there will be more and less during the lifetime of the grid component.
    a
    • 2
    • 4
  • x

    xxfast

    11/19/2022, 12:59 AM
    Trying to migrate to the new decompose API from
    0.6.0
    ->
    1.0.0-alpha07
    but i'm unable resolve the references on Android Studio Electric Eel 2022.1.1 Beta 5. The build just works fine so Im pretty sure this is an IDE issue. Any known workarounds for this? Related to https://github.com/arkivanov/Decompose/issues/190 i think
  • a

    Arkadii Ivanov

    11/19/2022, 9:01 AM
    Yeah, this is related to the newer Kotlin version and IDE issues. You can try different IDEs. Also you can try clean the project, delete .idea file, and reopen the project
    x
    • 2
    • 1
  • a

    Arkadii Ivanov

    11/19/2022, 9:03 AM
    I'm using the latest IDEA, works fine for me. I'm only getting unresolved Compose references in Android modules and androidMain source sets. But this is a bit different.
  • a

    Arkadii Ivanov

    11/19/2022, 10:10 PM
    The first Beta version of Decompose is released -
    1.0.0-beta-01
    ! - Added
    SimpleNavigation
    and exposed
    SimpleChildNavState
    for custom navigation implementations - Added main thread checks to
    MutableValue
    Provide old and new child stacks in
    StackRouterView#children
    function - Added
    disableInputDuringAnimation
    argument to
    stackAnimation
    function - Converted
    StackAnimation
    and
    StackAnimator
    interfaces to
    fun
    interfaces - Moved
    StackNavigation
    and
    OverlayNavigation
    factory functions next to the corresponding interfaces Please read the release notes - https://github.com/arkivanov/Decompose/releases/tag/1.0.0-beta-01
    a
    • 2
    • 1
  • m

    Marko Novina

    11/26/2022, 12:43 PM
    I have similar issue as mentioned in this message with `extensions-compose-jetbrains`: https://kotlinlang.slack.com/archives/C03H3N51SKT/p1668819580893639 But only when I build iOS app - either from Android Studio or from XCode. Do I maybe miss something? It doesn’t seem like same issue to me as this one since everything builds and works on Android but on iOS it fails when it tries to assemble shared module with same error. I will paste full error in 🧵.
    a
    • 2
    • 3
  • x

    xxfast

    11/28/2022, 11:55 PM
    Hi. Trying to migrate from
    back-pressed
    to
    back-handler
    api to enable predictive back for
    jetbrains-compose
    with the new
    StackNavigation
    . Previously (as of 0.6.0) we had to do
    val LocalBackPressedHandler: ProvidableCompositionLocal<BackPressedHandler?> = staticCompositionLocalOf { null }
    
    // On activity
    val backPressedHandler = BackPressedHandler(onBackPressedDispatcher)
    
    setContent {
      CompositionLocalProvider(LocalBackPressedHandler provides backPressedHandler) {
        ..
      }
    }
    is this no longer necessary given the
    ChildStack
    has a
    handleBackButton
    ?
    a
    • 2
    • 3
  • m

    Marc

    12/01/2022, 7:23 PM
    👋 i would like to use decompose stack router and was looking at how to make it work with different modules. Looks like alternatives such as the compose or flutter routers lean towards a uri based routing system. My idea is to use a config data class representing the route and then convert that to locations/destinations in the builder. Does this seem like a reasonable approach? Has anyone done something similar? Is this anyhow planned? The benefits i see are: • Implementing the web history or deeplinks would be trivial • Each module just needs to know the path, not any impl detail
    a
    • 2
    • 2
  • r

    rcd27

    12/01/2022, 11:00 PM
    [SOLVED] Greetings. Something weird is going on with my KMP project. I understand, it is in Alpha and all the stuff. This is "compose" module (doing the way it is done in
    decompose
    samples. Check this out, compiler complains, however build is OK and I actually can get the instance during runtime. The build.kts for this module is:
    ...
    sourceSets {
        all {
          languageSettings.apply {
            optIn("kotlin.RequiresOptIn")
            optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
            optIn("org.jetbrains.compose.ExperimentalComposeLibrary")
          }
        }
        val androidMain by getting {
          dependencies {
            api("androidx.appcompat:appcompat:1.5.1")
    
            implementation("androidx.compose.material3:material3:1.1.0-alpha02")
            implementation("androidx.compose.material3:material3-window-size-class:1.1.0-alpha02")
          }
        }
        val commonMain by getting {
          dependencies {
            implementation(project(":shared"))
    
            api(compose.runtime)
            api(compose.foundation)
            @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
            api(compose.material3)
    
            // Decompose
            implementation("com.arkivanov.decompose:decompose:1.0.0-beta-01")
            // Value<T>.subscribeAsState()
            implementation("com.arkivanov.decompose:extensions-compose-jetbrains:1.0.0-beta-01")
          }
        }
        val jvmMain by getting {
          dependencies {
            implementation(compose.desktop.currentOs)
          }
        }
      }
    ...
    a
    • 2
    • 11
  • a

    Arkadii Ivanov

    12/16/2022, 12:00 PM
    Decompose
    1.0.0-beta-02
    is released! - Added
    minAlpha
    argument to fade animator - Added a convenience overload function
    ComponentContext#children
    with
    Parcelable
    navigation state - Applied parcelize-darwin plugin, updated Essenty to
    0.7.0
    Release notes: https://github.com/arkivanov/Decompose/releases/tag/1.0.0-beta-02
  • r

    rcd27

    12/23/2022, 8:20 AM
    @Arkadii Ivanov greetings. You do have
    @Preview
    annotation in
    decompose
    samples. Do they work actually, or is there any hack around KMP to use preview feature yet? Please, share.
    a
    l
    • 3
    • 8
  • b

    Bogdan Cordier

    12/29/2022, 8:36 AM
    Hi @Arkadii Ivanov. In my application i’m using the childstack backstack to display or not a back arrow in a top app bar. If i quickly switch of apps and come back, the backstack will be empty but the navbar backbutton will navigate back to the previous screen, which seems odd to me. Shouldn’t the backstack be in sync with the navigation upon restoration or is there something i’m missing ?
    a
    • 2
    • 3
  • a

    Adam Brown

    12/29/2022, 8:51 PM
    Ok i've got a mix of gradle version/multiplatform version/intelliJ version that is actually working, no one touch anything 😂 except after updating various things, my Android Module now thinks it doesn't have a compose runtime:
    IncompatibleComposeRuntimeVersionException: The Compose Compiler requires the Compose Runtime to be on the class path, but none could be found. The compose compiler plugin you are using (version 1.3.2) expects a minimum runtime version of 1.0.0.
    Anyone run into this before?
    l
    • 2
    • 39
  • a

    Arkadii Ivanov

    01/04/2023, 1:22 PM
    Decompose
    1.0.0-beta-03
    is released! - Added
    backStackCreateDepth
    argument to
    Child Stack
    - Added
    persistent
    argument to
    Child Stack
    - Updated Essenty to
    0.8.0 (state preservation on JVM/desktop)
    Release notes: https://github.com/arkivanov/Decompose/releases/tag/1.0.0-beta-03
  • a

    Adam Brown

    01/09/2023, 11:14 PM
    hey what other stuff might you put in a Destination class other than the component it's self? All of mine so far are one to one, Destination -> Component
    a
    • 2
    • 12
  • f

    Francis Mariano

    01/11/2023, 5:41 PM
    hello, decompose already support compose for ios???
    l
    a
    +2
    • 5
    • 29
  • a

    Adam Brown

    01/20/2023, 2:31 AM
    huh you think I can bring in and start using the jetbrains compose 1.3.0 rc and decompose will be alright with it?
    r
    • 2
    • 2
  • m

    Marko Novina

    01/25/2023, 8:23 AM
    Anyone using Decompose + Compose Multiplatform + Koin combination? If so is there any way to inject decompose components directly into compose functions with Koin? I know there is a example of someting similar Arkadii did for Droidcon app, but there he passes components into compose functions. What I want is basically the same thing, but injecting components into functions instead of passing them. If I’m not mistaken Koin doesn’t support that for multiplatform compose, but did somebody tried to do something like that or has some workaround to do so? :thank-you:
    a
    • 2
    • 4
  • s

    sigmadelta

    01/25/2023, 3:27 PM
    Hi everyone, first of all thanks for the great effort and time invested in the Decompose library as I’m already enjoying the benefits it provides. Second, I’m currently using it in a Compose-Desktop application, and I’m in a situation where I need to launch a few coroutines but I’m a little bit confused as to how the
    main
    &
    io
    `CoroutineContext`s are defined. On the documentation page (https://arkivanov.github.io/Decompose/component/scopes/#creating-a-coroutinescope-in-a-component) I found following sample:
    fun CoroutineScope(context: CoroutineContext, lifecycle: Lifecycle): CoroutineScope {
        val scope = CoroutineScope(context)
        lifecycle.doOnDestroy(scope::cancel)
        return scope
    }
    
    fun LifecycleOwner.coroutineScope(context: CoroutineContext): CoroutineScope =
        CoroutineScope(context, lifecycle)
    
    class SomeComponent(
        componentContext: ComponentContext,
        mainContext: CoroutineContext,
        private val ioContext: CoroutineContext,
    ) : ComponentContext by componentContext {
    
        // The scope is automatically cancelled when the component is destroyed
        private val scope = coroutineScope(mainContext + SupervisorJob())
    
        fun foo() {
            scope.launch {
                val result =
                    withContext(ioContext) {
                        "Result" // Result from background thread
                    }
    
                println(result) // Handle the result on main thread
            }
        }
    }
    In the
    SomeComponent
    constructor you are passing
    mainContext
    and
    ioContext
    . Do these need to be defined in the
    RootComponent
    or just the parent component? And aside from that, how exactly are they instantiated? Thanks again
    a
    a
    • 3
    • 2
  • s

    Slackbot

    01/26/2023, 6:47 AM
    This message was deleted.
  • m

    Marc

    01/27/2023, 10:02 AM
    👋 i really enjoyed the droidcon app in which @Arkadii Ivanov explains how to “think in scopes” that get activated or deactivated in response to state. looks close to RIBs from UBER. anyway, there is an example on that talk about twitter screens. do you have a suggestion to split components into packages instead of all in one place and dependent from each other?
    a
    • 2
    • 4
  • a

    Adam Brown

    01/29/2023, 1:33 AM
    I'm trying to decide how to preserve some compose state (specifically a List's scroll state). I have screen A with the scroll state, and then screen B that uses the stack navigator to get pushed on top. And when that happens, I lose the state and
    remembers
    of screen A's composable. So when I pop screen B off the stack, screen A has lost where it was scrolled to in it's list. I think the strict compose answer to this is state hoisting. Something about that feels a little weird, but I suppose it can make sense?
    a
    • 2
    • 12
  • a

    Adam Brown

    01/31/2023, 5:05 AM
    I got a weird one here. So when using an animation with the
    Children
    composable, it subtly breaks certain things. I don't have a minimal case repro yet, but let me explain:
    a
    • 2
    • 11
  • p

    Pavel S

    01/31/2023, 8:41 PM
    How is DI supposed to be organized in Decompose? Judging by the samples, the parent component creates the child components and passes everything via constructor, however I’m not sure about a couple of things: 1. What if we need dependencies that live longer than the component, say application-level? Using them as singletons or passing some kind of service-locator everywhere doesn’t seem too elegant. Are there any other solutions? 2. How can components be distributed to separate feature-modules without cross-feature dependencies? In samples projects either all components are located in shared/common module or a feature depends on other features?
    a
    • 2
    • 1
  • a

    Arkadii Ivanov

    02/02/2023, 11:12 PM
    https://twitter.com/arkann1985/status/1621272744586317826
  • d

    doubov

    02/08/2023, 11:28 PM
    I'm seeing the following behavior, wondering why it could be happening: 1. Start with Child A 2. Modify Child A state 3. Navigate to Child B 4. Rotate the device 5. Go back to Child A 6. The state is lost The state gets retained properly if we rotate the device on Child A. Setting
    backStackCreateDepth
    to 1 does fix the bug, but I'm pretty sure this shouldn't be required. 🙏
    a
    • 2
    • 8
  • b

    benkuly

    02/28/2023, 5:39 PM
    Is there a way to circumvent stuff like?
    scope.launch(Dispatchers.Main.immediate) {
        navigation.replaceCurrent(...)
    }
    We do that do prevent runtime exceptions due to wrong coroutine context by some caller of a public API... is there a reason, why decompose enforces the main dispatcher?
    a
    • 2
    • 3
  • m

    Marc

    03/02/2023, 4:32 PM
    hey! thanks for decompose, it’s great. quick question. is it in the plans to implement common navigation models based on generic as part of decompose? backstack and dialog exist. maybe it makes sense to have carousel/pager (as seen in the samples) and other very common ones. generic navigation allows to do pretty much any navigation one can think of but i still think there may be value in adding some as most apps use similar nav schemes.
    a
    p
    • 3
    • 16
  • b

    benkuly

    03/03/2023, 7:35 AM
    I get the following exception in my tests after upgrading decompose to 1.0.0:
    Access from different threads is detected, must be on the main thread only.Current thread: AWT-EventQueue-0 @coroutine#5082. First thread: AWT-EventQueue-0 @coroutine#11.
    Thown here:
    withContext(Dispatchers.Main.immediate) {
        push(configuration, onComplete) // <--
    }
    Any idea what's the problem?
    a
    e
    • 3
    • 11
Powered by Linen
Title
b

benkuly

03/03/2023, 7:35 AM
I get the following exception in my tests after upgrading decompose to 1.0.0:
Access from different threads is detected, must be on the main thread only.Current thread: AWT-EventQueue-0 @coroutine#5082. First thread: AWT-EventQueue-0 @coroutine#11.
Thown here:
withContext(Dispatchers.Main.immediate) {
    push(configuration, onComplete) // <--
}
Any idea what's the problem?
a

Arkadii Ivanov

03/03/2023, 8:31 AM
Most likely you created the root component on non-UI thread. Try following https://arkivanov.github.io/Decompose/component/overview/#jvmdesktop-with-compose
If this is already what you are doing, or the problem is still there. Try adding the following at the very beginning of your application: fun main() { runOnUiThread { val value = MutableValue(0) value.value = 1 } // The rest of the code } This will remember the correct thread, and all subsequent violations should throw proper stack traces.
b

benkuly

03/03/2023, 8:38 AM
Hm okay. This does not work:
withContext(Dispatchers.Main.immediate)
Notice: It is common test-code. Therefore only a few view models are created...
a

Arkadii Ivanov

03/03/2023, 8:39 AM
Ahh, this is in tests. I missed that.
Could you post your test here?
b

benkuly

03/03/2023, 8:41 AM
I can try creating a minimal reproducer.
a

Arkadii Ivanov

03/03/2023, 8:42 AM
That would be very helpful
The problem may be that you are using the real main dispatcher in tests. This may trigger the check. And this also makes your tests asynchronous. You can pass all used dispatchers via constructor (with default values) and replace them in tests. E.g. with StandardTestDispatcher or UnconfinedDispatcher. I will add an API to disable main thread checks in the next version, just in case one still wants to use real Dispatchers.
e

Evegenii Khokhlov

03/03/2023, 9:20 AM
Also
kotlinx-coroutines-test
has very handy
Dispatchers.setMain()
method.
a

Arkadii Ivanov

03/03/2023, 9:21 AM
Yes, this can be also used. Here are some docs (Android, but still can be useful) - https://developer.android.com/kotlin/coroutines/test#setting-main-dispatcher
b

benkuly

03/03/2023, 9:26 AM
Setting
Dispatchers.setMain()
and don't using real main dispatchers was the trick. Thank you 🙂
View count: 6