https://kotlinlang.org logo
Docs
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
compose
  • g

    gaetan

    05/12/2019, 9:56 AM
    Does anybody know the link to Compose compiler code?
    r
    2 replies · 2 participants
  • s

    streetsofboston

    05/12/2019, 1:07 PM
    Currently, in a lot of our Android apps, our ViewModels emit sealed data-class instances that closely match the UI (Views), minimizing the code in the UI (Activities, Fragments). These sealed data-classes are very easy to test in plain unit-tests, since they have no dependencies on the Android platform. My question is: Will/does Compose generate instances of classes that are very easy to unit-test as well?
    👍 2
    r
    l
    6 replies · 3 participants
  • b

    bloder

    05/12/2019, 1:23 PM
    I don't know if I understood 100% of model struct, are we able to create a model with immutable values and the compiler considers the model itself as an observable or only mutable fields are supported?
    l
    4 replies · 2 participants
  • t

    themishkun

    05/12/2019, 4:22 PM
    also, when included in the other project, compose functions generate a weird message
    Stateless Functional Components (SFCs) should not be invoked, use <name_of_the_component />
    l
    r
    4 replies · 3 participants
  • e

    elizarov

    05/12/2019, 7:37 PM
    I wonder what’s the intended future for two conventions of using
    state
    (apart from
    +
    operator):
    var foo by +state { 0 } // property delegation to state
    var (foo, setFoo) = +state { 0 } // destructuring state
    Is the second-one just a React/JS gimmick because “we can” or is it really useful in some use-cases?
    ➕ 5
    r
    j
    2 replies · 3 participants
  • r

    ralf

    05/12/2019, 8:27 PM
    In our team Compose sparkled a lot of discussion. DSLs in Kotlin don’t need a compiler plugin. Why is compose different? Why is the compiler plugin necessary? Is it just there to avoid some boilerplate? (I haven’t looked at the source, yet)
    ➕ 2
    l
    m
    +5
    24 replies · 8 participants
  • r

    romainguy

    05/12/2019, 8:50 PM
    It is not an alpha
    👆 5
    t
    1 reply · 2 participants
  • r

    romainguy

    05/12/2019, 8:52 PM
    Again, that's why we only provide source code
    👍 2
    y
    2 replies · 2 participants
  • p

    pawegio

    05/12/2019, 9:16 PM
    I have one question related to Continuing Explorations slide from I/O talk. Does multithreaded layout mean possibility of having multiple UI threads? 🤔
    t
    j
    2 replies · 3 participants
  • p

    pawegio

    05/12/2019, 9:20 PM
    ok, I meant multiple UI threads per single app, but if it’s not about it, nevermind, thanks 🙂
    s
    r
    +1
    4 replies · 4 participants
  • l

    louiscad

    05/12/2019, 10:09 PM
    I wonder how heterogeneous lists/grids will be handled though.
    l
    1 reply · 2 participants
  • s

    streetsofboston

    05/12/2019, 10:21 PM
    @romainguy I agree with other folks' suggestions to have a blog post explaining (to some degree) what
    @Compose
    does behind the scenes, if you have time. From the dev site:
    A Compose application is made up of composable functions
    Is this in a Functional Programming kind of way, alá the type
    IO<T>
    from FP. Or am I way off base and is it something else entirely?
    ➕ 1
    l
    t
    +3
    8 replies · 6 participants
  • i

    itnoles

    05/13/2019, 1:29 AM
    I noticed the compose plugins have 1.0.0-alpha01 on the jar file?
    l
    2 replies · 2 participants
  • j

    Jurriaan Mous

    05/13/2019, 6:10 AM
    What are the main challenges to make compose multi platform? I understand that it is not a priority for Google now but how far does the design help and can people from the outside contribute for support?
    e
    m
    +5
    11 replies · 8 participants
  • t

    themishkun

    05/13/2019, 9:18 AM
    Did you look at noria project by JetBrains for reconcilation? https://github.com/JetBrains/noria-kt
    r
    l
    6 replies · 3 participants
  • l

    Loránd

    05/13/2019, 12:58 PM
    I am just curious, will compose let us use custom views and add them to the view tree?
    s
    1 reply · 2 participants
  • r

    ragunathjawahar

    05/13/2019, 1:28 PM
    There is also a
    ViewAdapter
    interface that allows us to use Android widgets in Compose.
    👍 1
    r
    r
    +1
    9 replies · 4 participants
  • r

    romainguy

    05/13/2019, 2:25 PM
    @rivu.chakraborty You shouldn't rely on the XML syntax so much, it's going away. Use the regular function call syntax instead.
    r
    t
    +3
    26 replies · 6 participants
  • s

    Sam

    05/13/2019, 2:29 PM
    Under the hood, is the composed hierarchy just represented flat via canvas paint?
    r
    r
    +1
    7 replies · 4 participants
  • z

    zak.taccardi

    05/13/2019, 4:54 PM
    Will it be possible to run Compose on a JVM (without Robolectric)? This would be very useful for speedy unit testing
    👍 4
    l
    2 replies · 2 participants
  • l

    Loránd

    05/14/2019, 6:42 AM
    I am not sure if this was mentioned at I/O but does anyone know how we would use compose when writing UI code for landscape devices or tablet/chrome os ?
    👌 1
    a
    2 replies · 2 participants
  • m

    mzgreen

    05/14/2019, 6:47 AM
    Another one is - what with saving state/process death? In old framework views have a possibility to save/restore their state, how about Compose?
    r
    g
    +2
    20 replies · 5 participants
  • b

    Breno

    05/14/2019, 7:41 AM
    Do you guys have already defined how (or if) Compose will work along with MotionLayout? I ask this because both seem to be walking in opposite directions: While Compose is aiming to eliminate XML altogether, MotionLayout (wich is also awesome) is relying in describing behavior through XML in spite of Code.
    t
    g
    +4
    17 replies · 7 participants
  • p

    Prateek

    05/14/2019, 8:11 AM
    I tried out compose and loved what I saw in the little time I spent with it. I have a question around the quick iteration aspect. If you take into consideration something like React Native/ Flutter, they both have some sort of hot reloading/code swapping on the fly built in to the framework, while creating declarative UIs will certainly improve the UI development cycle for Android can you guys comment on the additional infrastructure (if any) being setup to improve upon and add to the quick feedback loop so we can iterate more quickly upon the UI? _(apply changes is great and all but it’s still way behind hot reload 😅)_ Thanks for all the amazing work you guys are doing Cc @romainguy @Leland Richardson [G]
    s
    l
    3 replies · 3 participants
  • a

    Antanas A.

    05/14/2019, 8:30 AM
    Hi, could anyone explain how @Composable annotation works under the hood? Is it creates some kind of AST tree which is returned when calling annotated function? I'm thinking maybe this concept can be used generally for "Interpreter pattern" where any actions can be written as @Composable and when AST could be traversed and interpreted later.
    👍 2
    l
    r
    +2
    10 replies · 5 participants
  • m

    Matej Drobnič

    05/14/2019, 10:42 AM
    1. How would scrolling actions work? For example how would one tell the layout to scroll to the top? I guess you could create
    onScroll
    and then force developer to track the scroll position from outside? How would that work performance wise since scroll position can potentially update on every frame?
    a
    1 reply · 2 participants
  • m

    Matej Drobnič

    05/14/2019, 10:42 AM
    2. How would focus system work with compose?
    a
    l
    6 replies · 3 participants
  • m

    Matej Drobnič

    05/14/2019, 10:42 AM
    3. How would animations work? For example dataset change animations like RecyclerView.
    a
    1 reply · 2 participants
  • d

    dector

    05/14/2019, 3:09 PM
    ./studiow
    failed with
    Unzipping
    Building compose plugin
    sed: -e expression #1, char 0: no previous regular expression
    ./gradlew: 159: ./gradlew: $s/$/ \\/: not found
    sed: -e expression #1, char 0: no previous regular expression
    ./gradlew: 159: ./gradlew: $s/$/ \\/: not found
    Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
    Launched it manually, copied prebuilts, opened
    try-compose
    project. But sync is failing with (error in thread). Please, advice. 🙂
    d
    t
    6 replies · 3 participants
  • j

    James Ward

    05/14/2019, 4:15 PM
    Hi all, I've been learning about Compose and found the docs make an incorrect claim that they are pure functions: https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/compose/README.md I've sent a pull request to fix that: https://android-review.googlesource.com/c/platform/frameworks/support/+/958319 Would be great to get someone to review that.
    👍 5
    c
    j
    +3
    21 replies · 6 participants
Powered by Linen
Title
j

James Ward

05/14/2019, 4:15 PM
Hi all, I've been learning about Compose and found the docs make an incorrect claim that they are pure functions: https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/compose/README.md I've sent a pull request to fix that: https://android-review.googlesource.com/c/platform/frameworks/support/+/958319 Would be great to get someone to review that.
👍 5
c

Chuck Jazdzewski [G]

05/14/2019, 4:20 PM
+2
j

James Ward

05/14/2019, 4:20 PM
Thanks!
j

Jeremy

05/14/2019, 4:33 PM
Yes I was also thinking that during presentation
c

Chuck Jazdzewski [G]

05/14/2019, 4:37 PM
The point we were trying to make is that the only side-effect the function should have is producing the tree. There isn't really a well understood term for that. The closest is monad but then only 5 people know what that means.
☝️ 4
j

Jeremy

05/14/2019, 4:57 PM
Why not: fun Greeting(name: String): Composable { return Text(text = "Hello $name") }
🇳🇴 1
💯 1
😱 1
t

themishkun

05/14/2019, 5:28 PM
@Chuck Jazdzewski [G] partially pure functions, then?
👍 1
g

ghedeon

05/14/2019, 5:28 PM
The closest is monad but than only 5 people know what that means
But who would think that so many people know what pure function means and now they are giving you hard time for not being transparent... referentially :troll:
r

romainguy

05/14/2019, 5:33 PM
@themishkun Pragmatically pure :)
😒imple_smile: 5
@ghedeon James doesn't count, he's a fan of Scala :)
👍 3
t

themishkun

05/14/2019, 5:35 PM
@romainguy yeah, kotlin fans LOVE the word "pragmatically" :)
c

Chuck Jazdzewski [G]

05/14/2019, 5:37 PM
@Jeremy That would work and is the approach take by React and Flutter. However, there is more opportunity for optimization along the line we took. For example if "name" is the same on recomposition we can skip the call entirely. We don't need to compare its result from last time to tell that it doesn't change. This is similar to the approaches taken by, for example, Ember and Angular.
🤔 1
➕ 2
☝️ 2
t

themishkun

05/14/2019, 5:42 PM
@Chuck Jazdzewski [G] is this really takes so much work to compare two `id`s in two generated data structures? In my team most screens consist of root recyclerviews with adapters for buttons, galleries, texts and titles, etc. and we see no perfomance impact on that.
j

Jeremy

05/14/2019, 5:48 PM
🤔 I think I just need to dig into more. Its just less clear from example what its actually doing
c

Chuck Jazdzewski [G]

05/14/2019, 5:48 PM
The
RecyclerView
is doing a lot of work behind the scenes to deliver this performance.
j

Jeremy

05/14/2019, 5:52 PM
Is there any examples of unit tests? If multiple tests are executing does any global state need to be reset?
👍 1
c

Chuck Jazdzewski [G]

05/14/2019, 6:08 PM
@Jeremy There are many unit tests in the repository and they can be found in the
androidTest
directory of the various modules. The memoization information is stored in the composer's slot table and is local for the composition. It is not global. However, currently we use a global to simplify the code generation of composable functions so only one composition can be occurring at a time. We plan to change this to rewrite composable functions to take the composer as a parameter. This will remove global as well as speed up composition.
j

Jeremy

05/14/2019, 6:29 PM
Thanks for response. I'll dig through the androidTest code a bit more
So api would be : fun Greeting(name: String, compose: Composable) ?
c

Chuck Jazdzewski [G]

05/14/2019, 6:40 PM
There will be a synthetic function produced with the parameter. The API will remain that same at the source level. We will redirect calls to composable functions to the synthetic.
👍 1
j

James Ward

05/15/2019, 1:53 AM
Sorry I missed the chatter here. It's definitely not monadic either. I don't think we should try to use any FP terms since the FP zealots will freak out. I'm not quite a zealot, just an advocate of using terms correctly.
I don't know what is really going on with Composable but it does seem like the API could use an IO Monad instead but you would need a return statement which I'll admit doesn't seem as nicely declarative as what exists today.
View count: 7