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
javascript
  • b

    bashor

    11/24/2017, 6:00 PM
    (^^^ thread)
    • 1
    • 1
  • n

    natpryce

    11/24/2017, 6:23 PM
    Does anyone have an example of using the kotlin-react library with existing Javascript React components? I’m completely baffled as to how to instantiate a JS react component from Kotlin, since the
    child
    method takes a KClass or reified type parameter of the child component to construct, neither of which is available for extern interfaces
    l
    f
    • 3
    • 5
  • b

    benjaminsutter

    11/26/2017, 5:03 AM
    As far as I can tell, Kotlin's JS support isn't quite the same idea as Nashorn.
    k
    • 2
    • 3
  • l

    lewik

    11/26/2017, 3:42 PM
    Is there any way to disable
    id_qzvhcz$_0
    in most cases automatically?
    s
    • 2
    • 1
  • r

    redrield

    11/26/2017, 10:58 PM
    data-* don't seem to have anything I can manipulate, even under attrs
    k
    f
    • 3
    • 4
  • b

    benleggiero

    11/27/2017, 1:39 AM
    How do I call
    toFixed
    from Kotlin? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
    g
    • 2
    • 2
  • g

    Greg Stepniewski

    11/27/2017, 7:53 PM
    is there an easy way to do xml serialization in kotlinjs?
    g
    • 2
    • 3
  • p

    pakoito

    11/27/2017, 11:59 PM
    is there a kotlinjs equivalent of WeakReference?
    k
    p
    • 3
    • 13
  • r

    redrield

    11/28/2017, 4:05 AM
    How could I do that?
    k
    • 2
    • 7
  • n

    natpryce

    11/28/2017, 2:24 PM
    If I call the constructor of the data class instead, my app works fine. It’s only calls to the copy function that fail in this way
    k
    • 2
    • 27
  • d

    Dmitry Kandalov

    11/28/2017, 3:51 PM
    Hi. What is the best way to write unit tests for kotlin js?
    k
    i
    a
    • 4
    • 3
  • j

    Jurriaan Mous

    11/28/2017, 9:58 PM
    Is it possible to run those javascript unit tests from the gutter run icons? For me they keep saying “Nothing here” while they run all together with Jest in gradle.
    b
    a
    a
    • 4
    • 11
  • j

    Jurriaan Mous

    11/29/2017, 7:49 AM
    I am also still curious if it is possible to run specific Kotlin JS tests from the gutter or tree view.
    g
    • 2
    • 2
  • f

    fstn

    11/29/2017, 1:11 PM
    Hi, how can I compile only one folder (models) to javascript?
    k
    • 2
    • 2
  • d

    Danilo

    11/29/2017, 3:51 PM
    A thing that I dont know. Can we always write our code using 'dynamic' instead of writing wrappers? For example, this react wrappper, it is really needed or is just to organize the things?
    k
    f
    • 3
    • 3
  • d

    DomDom

    11/30/2017, 3:22 PM
    hi all, just wanna try kotlin for javascript but it seems create-react-kotlin-app does not work behind a corporate firewall. any idea ?
    f
    • 2
    • 5
  • l

    laht

    11/30/2017, 8:10 PM
    Currently I have implemented wrappers for dat.GUI that ships with the three.kt wrappers above. The problem is that the code wont run without loading dat.GUI.js runtime. I want it to be optional
    b
    • 2
    • 15
  • l

    laht

    11/30/2017, 8:27 PM
    Ok, so what happens is that I import the dat.GUI wrapper in one example -> I need to import dat.GUI.js for all my examples in the project even if I dont use the library. Becouse dat.GUI gets referenced in the single output file examples.js
    b
    p
    • 3
    • 37
  • g

    gaetan

    11/30/2017, 11:04 PM
    I have a bug but I don’t know if it’s already in youtrack:
    fun main(args: Array<String>) {
        
        var one = '1'
        one shouldEqual '1'
        
        val foo = Foo('2')
        foo.bar shouldEqual '2'  //<- should not complain, but it does.
    }
    
    class Foo(val bar:Char = ' ')
        
    infix fun <T> T.shouldEqual(any: Any?): Unit {
        if (this != any)
            println("$this did not equal $any")            
    }
    To try it online: https://try.kotlinlang.org/#/UserProjects/vt8l2cck3f0fak5t0ks4grpqlr/ai0kcea10ier1sgnj02g0eqiop
    k
    • 2
    • 1
  • s

    s1m0nw1

    12/01/2017, 9:50 AM
    Anyone using
    kotlin-runcode
    ? I'd need help 🙂
    b
    r
    • 3
    • 5
  • s

    spand

    12/01/2017, 2:20 PM
    Say I require jQuery in my kotlin/js so it is not available globally as $. How do I define an interface for it that both have properties and can be invoked?
    k
    • 2
    • 9
  • k

    kirillrakhman

    12/01/2017, 6:25 PM
    is there a documentation on how to publish a kotlin-js library to maven (local)?
    g
    l
    n
    • 4
    • 7
  • d

    Danilo

    12/01/2017, 8:16 PM
    Hi guys, if I would like to create a wrapper to a js library myself (let say angular 5, for example). Is there a kind of guide or best practices to do this? For example here: https://github.com/Kotlin/kotlin-fullstack-sample/tree/master/frontend/src/org/jetbrains a React wrapper was created.
    k
    f
    • 3
    • 8
  • d

    Danilo

    12/01/2017, 8:18 PM
    The way that why the React wrapper was created that way is a kind obscure to me. I think will be wonder if we have some kind of repo like the https://github.com/DefinitelyTyped/DefinitelyTyped full with kotlin wrappers
    k
    p
    • 3
    • 4
  • a

    arocnies

    12/02/2017, 4:48 AM
    Does anyone know where to find an example of a Kotlin React app that uses Gradle?
    k
    • 2
    • 1
  • j

    jv

    12/02/2017, 9:42 PM
    is there a built in way to filter the DOM by class name, such that it captures arbitrarily deep elements?
    k
    • 2
    • 3
  • j

    jv

    12/03/2017, 2:29 AM
    I'm querying some elements from the DOM of which I stick into a List, when I check the count() of the list I get back 1, when I try to reference the object within the list I seem to crash my script. Is this related to the dynamic attribute some how?
    k
    • 2
    • 1
  • f

    Filipp Riabchun

    12/03/2017, 11:07 AM
    Thread for above discussion :thread-please:
    • 1
    • 2
  • k

    kylpo

    12/04/2017, 3:39 AM
    Hi friends. I'm trying to get
    babel-loader
    running from an ejected
    create-react-kotlin-app
    . With no babel plugins enable, it is erroring with
    TypeError: Kotlin.defineModule is not a function
    .
    h
    • 2
    • 1
  • k

    kylpo

    12/04/2017, 3:42 AM
    (I'm doing a spike to see if a css-in-js solution with a babel-transform step will work for a Kotlin web app)
    f
    b
    • 3
    • 24
Powered by Linen
Title
k

kylpo

12/04/2017, 3:42 AM
(I'm doing a spike to see if a css-in-js solution with a babel-transform step will work for a Kotlin web app)
f

Filipp Riabchun

12/04/2017, 11:20 AM
Which solution do you mean, namely? Currently, KotlinJS can't output anything other than ES5 code
k

kylpo

12/04/2017, 1:46 PM
Ahh, that would explain why I can't use backticks in my
js()
calls 😞
I'm trying to use Linaria or Emotion which rely on a syntax like:
css`
  background: red;
`
and this kotlin line errors at compile because of the backticks:
js("css`background: red;`")
f

Filipp Riabchun

12/04/2017, 1:50 PM
do you use interpolations inside it?
that is,
${expression}
k

kylpo

12/04/2017, 1:51 PM
Not always. It is just a syntax needed for the babel transform to strip out the css and create a classname
f

Filipp Riabchun

12/04/2017, 1:51 PM
When you don't, you can just call it like a function
css(Array("""
  background: red;
"""))
triple double quotes are for multiline strings in Kotlin
k

kylpo

12/04/2017, 1:52 PM
Hmm, oh, nice!
f

Filipp Riabchun

12/04/2017, 1:53 PM
With interpolations, it would be a lot more tricky
k

kylpo

12/04/2017, 1:53 PM
I'll try that right now. 1 min, please.
f

Filipp Riabchun

12/04/2017, 1:55 PM
Oh, it should be an array not a string
k

kylpo

12/04/2017, 1:55 PM
Ah, yeah, unfortunately, I still need it to output from kotlin to js with the backticks.
See https://github.com/callstack/linaria for the syntax required for the babel transform
f

Filipp Riabchun

12/04/2017, 1:56 PM
@bashor is there a plan to support targets other than ES5?
k

kylpo

12/04/2017, 2:00 PM
Thanks for your help, @Filipp Riabchun!
b

bashor

12/04/2017, 2:29 PM
is there a plan to support targets other than ES5?
Yes, but only after we will finish migrating to the new compiler infrastructure. Not very soon.
Feel free to vote or star the related issue to get notification about updates https://youtrack.jetbrains.com/issue/KT-8373
k

kylpo

12/04/2017, 2:31 PM
Thanks, will do! For now I'll hope to use Kotlinjs to share business logic, but likely not be able to use it in any React/View code 😢
f

Filipp Riabchun

12/04/2017, 2:35 PM
Well you can have part of your codebase in js and part in Kotlin
k

kylpo

12/04/2017, 2:37 PM
Yeah. Hopefully all in Kotlin some day 🙂
b

bashor

12/05/2017, 9:57 AM
I think JS css will look strange inside Kotlin code. I think it would be better to implement DSL in Kotlin.
View count: 2