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
  • g

    gildor

    01/16/2018, 5:02 AM
    Just declare extension function for that:
    fun Any.hasOwnProperty(property: String): Boolean {
        return asDynamic().hasOwnProperty(property) == true
    }
    f
    a
    b
    • 4
    • 7
  • g

    gildor

    01/16/2018, 5:07 AM
    Or even
    infix fun String.`in`(obj: Any): Boolean {
        return obj.asDynamic().hasOwnProperty(this) == true
    }
    // "ontouchstart" `in` window
    but I like first option more
    f
    • 2
    • 1
  • a

    anton.bannykh

    01/16/2018, 2:28 PM
    Unfortunately`js("p in this")` translates to
    p in this
    , not to
    p in $receiver
    . Thus the temporary
    obj
    variable.
    f
    • 2
    • 5
  • y

    yaakov

    01/16/2018, 6:00 PM
    I wish I could make the chrome console execute kotlin/js
    :youtrack: 1
    ❤️ 1
    b
    • 2
    • 2
  • g

    gildor

    01/17/2018, 12:56 AM
    Are there any plans to support Kotlin/JS expression execution in IDEA during js debugging? Same way as you use Kotlin during JVM debugging
    a
    b
    • 3
    • 2
  • j

    Jurriaan Mous

    01/17/2018, 3:16 PM
    I have a problem to run my tests with method names with spaces inside backticks. I get the following error from gradle:
    e: $PATH: Name contains illegal chars that can't appear in JavaScript identifier
    :js:compileTestKotlin2Js FAILED
    From the style guide: https://kotlinlang.org/docs/reference/coding-conventions.html#names-for-test-methods
    In tests (and only in tests), it's acceptable to use method names with spaces enclosed in backticks. (Note that such method names are currently not supported by the Android runtime.) Underscores in method names are also allowed in test code.
    It only mentions that this is not working in Android so I assume it should work in JS. Am I doing something wrong or are they not supported at the moment? Using Kotlin 1.2.20
    a
    s
    e
    • 4
    • 6
  • a

    actsasgeek

    01/17/2018, 9:40 PM
    I have a Gradle-based JavaScript project I started in IntelliJ. It “works” in the sense that I can type
    ./gradle build
    and it builds but in IntelliJ itself, when I’m in the Kotlin file, it says, in a greenish bar, “Kotlin not configured” and I can’t figure out what isn’t configured.
    s
    • 2
    • 1
  • a

    actsasgeek

    01/17/2018, 10:22 PM
    alrighty. It appears the other computer was using 1.2.10. After upgrading to 1.2.20; it now appears to be working…very strange indeed.
    b
    • 2
    • 4
  • s

    spierce7

    01/18/2018, 3:42 PM
    I found a community supported react-native bundler that uses webpack instead of facebooks custom bundler: https://github.com/callstack/haul . How do I get webpack to recognize and pull in my sourcemaps?
    a
    • 2
    • 2
  • d

    Deactivated User

    01/18/2018, 7:39 PM
    Not sure if reported already (bad code generation in 1.2.20, related to longs and ranges): https://github.com/korlibs/korio/blob/01d5ef0b03094620ae5fa8194c0b0848d04d7170/korio/common/src/main/kotlin/com/soywiz/korio/stream/SyncStream.kt#L169
    MemorySyncStreamBase.prototype.read_4m9kcn$ = function (position, buffer, offset, len) {
        var tmp$;
        this.checkPosition_s8cxhz$(position);
        tmp$ = this.length;
        if (!((0).lessThanOrEqual(position) && position.lessThan(tmp$)))
          return 0;
        var end = min(Math_0, this.length, position.add(Kotlin.Long.fromInt(len)));
        var a = end.subtract(position).toInt();
        var actualLen = Math_0.max(a, 0);
        arraycopy(this.data.data, position.toInt(), buffer, offset, actualLen);
        return actualLen;
      };
    0.lessThanOrEqual(position) <--
    if (!((0).lessThanOrEqual(position) && position.lessThan(tmp$)))
    return 0;
    TypeError: 0.lessThanOrEqual is not a function
          at MemorySyncStreamBase.read_4m9kcn$ (korio-js.js:23710:15)
          at SliceSyncStreamBase.read_4m9kcn$ (korio-js.js:23581:30)
          at SyncStream.read_mj6st8$ (korio-js.js:23499:26)
          at readBytes_0 (korio-js.js:23847:36)
          at readString_0 (korio-js.js:23805:23)
          at ImageFormats.readImage_1ooaqm$$default (korim-js.js:6284:85)
          at ImageFormats.ImageFormat.readImage_1ooaqm$ (korim-js.js:5666:65)
          at ImageFormats.ImageFormat.read_zdd1ed$ (korim-js.js:5759:17)
          at Coroutine$ImageFormat$decodeInWorker$lambda.doResume (korim-js.js:5933:48)
          at korim-js.js:5911:25
          at KorioNative.executeInWorker_lnyleu$ (korio-js.js:38407:12)
          at executeInWorker (korio-js.js:6831:38)
          at ImageFormats.ImageFormat.decodeInWorker_nwlife$ (korim-js.js:5953:12)
          at Coroutine$readBitmapNoNative_0.doResume (korim-js.js:9536:48)
          at Coroutine$readBitmapNoNative_0.CoroutineImpl.doResumeWrapper_0 (kotlin.js:3630:27)
    a
    • 2
    • 7
  • j

    jw

    01/19/2018, 12:57 AM
    I wonder if kotlinx.serialization can be used to "serialize" it to a JS object and "deserialize" it from a JS object
    b
    • 2
    • 1
  • f

    fitzoh

    01/19/2018, 2:36 AM
    is there a npm package for coroutines? I’m failing at the google
    a
    • 2
    • 14
  • a

    Alex Fridlyand

    01/19/2018, 10:40 AM
    Hello, i’m new to kotlinx.html dsl library, but spend quite some time to understand how to write styling in production with create-react-kotlin-app I’ve a big scss/SASS files that i would like to port for the most Kotlin-inspired-way in terms of styling. I’ve heard that guys at Jetbrains are using it for the products, so what’s the best approach? Go back to css? Write jsx with js = {} I’ve big amount of classes in scss like : “.mainheader { &__content” so it doesn’t seem to work with classes as a Set<String>
    a
    h
    +2
    • 5
    • 38
  • s

    spierce7

    01/19/2018, 4:50 PM
    What's the best way to make an external binding for a javascript function that takes a js object as a parameter?
    Platform.select({
      ios: 'iOS',
      android: 'android',
    });
    a
    g
    • 3
    • 9
  • s

    spierce7

    01/21/2018, 7:49 PM
    I created an example of a working react-native application that uses Kotlin-js in case anyone else wanted kotlin w/ react-native: https://github.com/ScottPierce/kotlin-react-native
    👍 11
    u
    b
    • 3
    • 6
  • b

    birgersp

    01/22/2018, 1:01 PM
    I'd rather not have to manually copy the script to my web-application every time i build it...
    d
    a
    b
    • 4
    • 15
  • b

    birgersp

    01/22/2018, 2:24 PM
    Idk if what I'm saying makes any sense, but I want the artifact to be built automatically when I change the source code. I'd rather not have to keep pressing "build" to make the artifact build every time I change the source code...
    a
    • 2
    • 2
  • m

    marcinmoskala

    01/23/2018, 7:34 AM
    I see that function names like:
    fun `This is my function name`() {}
    are not allowed in JS. Are they going to be?
    a
    • 2
    • 1
  • m

    mmaillot

    01/23/2018, 9:37 PM
    Hi! I try to create firebase HTTP trigger function with Kotlin. Firebase uses expressjs and I want to wrap this lib in Kotlin. Do you have any resources to explain how to do that ?
    g
    • 2
    • 6
  • b

    benleggiero

    01/24/2018, 2:44 AM
    Is there any way to silence this compiler error?
    Error (51, 5): Kotlin: Overriding `external` function with optional parameters
    b
    a
    • 3
    • 6
  • h

    Hugh Bollen

    01/24/2018, 4:07 AM
    Hi! I'm trying to create a button that returns a user to the top of the webpage. document.documentElement?.scrollTop = 0.0 is the slightly edited code I'm using from https://www.w3schools.com/howto/howto_js_scroll_to_top.asp but I'm having trouble implementing in Kotlin. Have you got any ideas?
    g
    • 2
    • 3
  • s

    steamstreet

    01/24/2018, 5:35 AM
    Is the Kotlin-frontend-plugin still in active development? Just submitted a pull request to fix it for 1.2.20, but it seems somewhat dormant.
    a
    h
    c
    • 4
    • 5
  • f

    Filipp Riabchun

    01/25/2018, 10:02 AM
    For external modules, you don't need to declare acctual class See https://github.com/JetBrains/kotlin-wrappers/blob/master/examples/src/main/kotlin/example/Quill.kt#L13-L19 for sample usage
    b
    • 2
    • 1
  • m

    Michael Kotlikov

    01/25/2018, 12:04 PM
    how do i add an
    &nbsp;
    into an element? it keeps appearing as normal text😞
    s
    f
    • 3
    • 10
  • t

    timm

    01/30/2018, 4:55 PM
    is there an up to date guide on how to get the dce plugin working with the frontend plugin?
    b
    c
    • 3
    • 4
  • r

    rellenberger

    01/31/2018, 5:21 PM
    Does Kotlin work well with Polymer or Angular Elements?
    a
    g
    • 3
    • 4
  • m

    mmaillot

    01/31/2018, 8:44 PM
    I try to develop firebase function with Kotlin in place of JS. In first place, I want to wrap expressjs (used by firebase to create endpoint). This is my code :
    val expressLib = require("express")
    
    class Express(val app: dynamic = expressLib()) {
    
        fun get(route: String, callback: (req: Request, res: Response) -> Unit) {
            app.get(route, { req, res ->
                val request = Request(req)
                val response = Response(res)
                callback(request, response)
            });
        }
    
    }
    
    class Response(private val responseJs: dynamic) {
    
        fun send(data: String): Response {
            return Response(responseJs.send(data))
        }
    
        fun json(data: Any): Response {
            return Response(responseJs.send(data))
        }
    
    }
    Is it a good approach ?
    a
    l
    • 3
    • 25
  • s

    spierce7

    02/01/2018, 1:37 AM
    Is there a way to do code-coverage with Kotlin-js tests?
    a
    g
    • 3
    • 3
  • g

    gaetan

    02/01/2018, 12:28 PM
    I think I have a bug on kotlin js:
    fun main(args: Array<String>) {
    	sayHello().talk()   
    }
    
    fun  sayHello() = HelloGenerator().apply {
        //talk = this::helloFunction // <- OK on jvz and js
        talk = ::helloFunction  // <- OK on jvm, KO on js
    }
    
    class HelloGenerator {
        var talk: () -> Unit = ::helloFunction
        fun helloFunction() { println("hello world") }
    }
    a
    • 2
    • 9
  • s

    spierce7

    02/01/2018, 6:27 PM
    How do I split up my app into multiple separate modules? I tried moving my external definitions into libraries, and then compile them into my main module, and I'm getting errors running my code now. If I move it all back into 1 module, the error goes away.
    a
    • 2
    • 6
Powered by Linen
Title
s

spierce7

02/01/2018, 6:27 PM
How do I split up my app into multiple separate modules? I tried moving my external definitions into libraries, and then compile them into my main module, and I'm getting errors running my code now. If I move it all back into 1 module, the error goes away.
a

anton.bannykh

02/02/2018, 11:00 AM
What kind of error are you getting?
Could it be the library you need is not `require`'d?
s

spierce7

02/02/2018, 2:54 PM
probably. Do I need to export the library with the same module kind as my compiled module?
a

anton.bannykh

02/02/2018, 2:58 PM
Make sure you are actually using declarations marked with
@JsModule
.
Or mark the whole file with declarations (
@file:JsModule("the-library-this-is-for-name")
)
(Depending on what the library you are writing declarations for actually exports)
View count: 5