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

    Dmitry Kandalov

    12/23/2017, 4:56 PM
    Hi. I have kotlinjs amd module which generates js file starting with
    define(['exports', 'kotlin', ....
    . However, to load it in npm I need to require 'amdefine' first, as described here http://requirejs.org/docs/node.html#nodeModules there should be a line like this at the top of the generated file
    if (typeof define !== 'function') { var define = require('amdefine')(module); }
    Is there any way to do it in kotlinjs?
    f
    b
    • 3
    • 6
  • f

    fuad

    12/23/2017, 6:47 PM
    There are no pre-reqs for my course so some students have JS exposure and some may have never even programmed before. It’s a really hard balance to strike and still keep all the students engaged yet not struggling.
  • l

    littlelightcz

    12/26/2017, 2:23 PM
    aaahah! When I changed it to @JsModule("react-select/dist/react-select.js"), the error is gone 😄 so maybe that's the proper way ...
    n
    b
    • 3
    • 8
  • x

    xap4o

    12/26/2017, 8:03 PM
    I watched KotlinConf video "How to Build a React App in Kotlin by Dave Ford". Now I'm trying to reproduce this setup for rapid development. But I have problem: create-react-kotlin-app@1.0.6 doesn't perform hot module swapping for Kotlin code (only for CSS). And exactly this behaviour is described in docs https://github.com/JetBrains/create-react-kotlin-app/blob/3906d92c8111608c662ad2abdd3140f62b6368ec/packages/react-scripts/config/webpackDevServer.config.js#L65 But somehow during live demo speaker managed to get it work. I wonder how.
    b
    h
    • 3
    • 6
  • l

    lukas.fink

    12/27/2017, 1:48 PM
    I’m using
    kotlinx.html
    in javascript to get the value from an
    input
    field. Is there a more elegant solution than doing it this way?
    b
    • 2
    • 2
  • t

    trevjones

    12/28/2017, 7:05 PM
    looking like it is related the the scope I am using it in
    b
    • 2
    • 13
  • b

    benleggiero

    12/29/2017, 1:12 AM
    Is it possible to use JavaScript’s
    >>
    operator in Kotlin/JS?
    g
    • 2
    • 7
  • h

    hiperbou

    12/29/2017, 1:46 PM
    Try it changing versions in: https://try.kotlinlang.org/#/UserProjects/9chibhvpjdpgrvn25sfioqi1di/b12hmnaehl9i068btfhcnj3283
    b
    • 2
    • 1
  • j

    jossiwolf

    12/30/2017, 12:48 AM
    I'm working on an article about Kotlin and JavaScript, would somebody mind looking over it?
    b
    • 2
    • 2
  • g

    gbaldeck

    01/02/2018, 7:38 PM
    Hi guys, if you're interested in using VueJS with Kotlin my Vue.kt repo is becoming stable. The VueJS wrapper portion is almost complete and one additional feature I plan on adding is dependency injection. Now is a good time to start learning how to use it if you're interested.
    👍 1
    👏 3
    d
    • 2
    • 3
  • g

    gbaldeck

    01/03/2018, 1:12 AM
    What are the situations where the compiler adds a postfix to methods and properties when it generates them? Sometimes it happens in the generated code and then sometimes it doesn't. For the wrapper I'm making it would be nice to know when that is going to happen so that I can handle it appropriately
    d
    b
    • 3
    • 6
  • s

    spierce7

    01/03/2018, 1:25 PM
    Is there a kotlin.js library compiled as a plain js library? The bundler that react-native is using seems to freeze trying to bundle the kotlin.js library
    g
    b
    b
    • 4
    • 28
  • j

    jw

    01/05/2018, 7:20 AM
    how do I map a structured type to an anonymous object?
    b
    • 2
    • 14
  • j

    jw

    01/05/2018, 7:26 AM
    I'm after
    { param1: arg1, param2: arg2, .. }
    g
    • 2
    • 2
  • y

    yaakov

    01/06/2018, 10:29 PM
    She got offended quickly 😛 On a more serious note, using Kotlin2JS is actually a lot easier than I thought. I was imagining the project setup to be a bit of a pain for some reason.
    g
    • 2
    • 1
  • l

    lewik

    01/07/2018, 11:48 AM
    Is there api like
    $('.myClass').innterText = "new text"
    for xml string?
    b
    • 2
    • 12
  • j

    jw

    01/07/2018, 10:36 PM
    oh apparently they share an API
    n
    k
    • 3
    • 6
  • b

    birgersp

    01/09/2018, 2:36 PM
    Whoops, seems I was a bit too hasty with my assumptions. I got it working now. Thanks!
    d
    • 2
    • 1
  • s

    spierce7

    01/09/2018, 8:02 PM
    Does anyone know a way to split the kotlin.js file into multiple files? I'm trying to find a work-around for https://youtrack.jetbrains.com/issue/KT-22150
    b
    • 2
    • 5
  • b

    birgersp

    01/10/2018, 2:04 PM
    @gildor Are you asking me?
    g
    • 2
    • 1
  • l

    louiscad

    01/10/2018, 10:15 PM
    @spierce7 Using
    ::YourConstructor
    ?
    s
    s
    • 3
    • 5
  • j

    jrtapsell

    01/10/2018, 10:26 PM
    Is there a way to make an external class that can be called in JS without a method
    a
    • 2
    • 1
  • m

    mattinger

    01/10/2018, 11:23 PM
    now if i could get iOS library targeting, my life would be a lot simpler.
    ❓ 2
    l
    n
    • 3
    • 5
  • s

    spierce7

    01/11/2018, 6:18 PM
    I'm having trouble getting my external definitions into react-native. I'm not a javascript expert, so I'm struggling a little bit. react-native uses babel to package things together via import statements, and those import statements pull code in from npm (I think). I've setup external definitions in Kotlin, but the Kotlin generated js can't find the js libraries from npm unless I manually edit the kotlin generated js file and add import statements at the top:
    import React from 'react';
    import {AppRegistry, StyleSheet, Text, View} from 'react-native';
    How should I be giving the kotlin code access to the npm libraries without manually editing the js file kotlin generates?
    s
    • 2
    • 6
  • s

    spierce7

    01/12/2018, 12:51 AM
    React-native runs all code in a chrome browser when in debug mode (communicating with the native application through a socket). Is there any way to hook IntelliJ up to chrome and debug through code in the IDE, instead of chrome?
    b
    • 2
    • 2
  • w

    w

    01/14/2018, 4:21 PM
    Just wondering if it is mature and stable enough to try it
    j
    • 2
    • 1
  • c

    cdietze

    01/14/2018, 7:32 PM
    I have a multi platform kotlin lib that I build using gradle. How can use that in a create-react-kotlin-app project?
    a
    h
    • 3
    • 3
  • a

    albertgao

    01/15/2018, 1:38 AM
    I have a KotlinJS project, under the
    src
    , there are 8 modules: 7 of them depends on 1 module. Previously I just import the
    lib
    in the libs folder, and run the
    Build
    command from menu, everything works, I get the
    .js
    files. Now I want to use
    gradle
    to do the building, is there a way that I can build the seven modules one by one with dependency on that 1 module? Within one
    build.gradle
    ?
  • i

    ilya.gorbunov

    01/15/2018, 2:14 AM
    You still need to declare 8 subprojects -- one for each module -- in settings.gradle. You can configure them all in a single build.gradle if you want, though usually each subproject gets its own build.gradle.
    a
    • 2
    • 1
  • t

    Tristan Caron

    01/15/2018, 2:07 PM
    Hello already tried to use MutationObserver? I want to observer an input element:
    val el = document.querySelector("#my-element")!! as HTMLInputElement
        val observer = MutationObserver { _, _ ->
            println("changes")
        }
    
        observer.observe(el, MutationObserverInit(attributes = true))
    But I'm always getting
    Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': The provided value cannot be converted to a sequence.
    Any ideas?
    a
    • 2
    • 5
Powered by Linen
Title
t

Tristan Caron

01/15/2018, 2:07 PM
Hello already tried to use MutationObserver? I want to observer an input element:
val el = document.querySelector("#my-element")!! as HTMLInputElement
    val observer = MutationObserver { _, _ ->
        println("changes")
    }

    observer.observe(el, MutationObserverInit(attributes = true))
But I'm always getting
Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': The provided value cannot be converted to a sequence.
Any ideas?
a

anton.bannykh

01/15/2018, 3:37 PM
Could you try passing
MutationObserverInit(attributes = true, attributeFilter = undefined)
instead?
@Tristan Caron I've been able to reproduce the error. It seems that the default value of attributeFilter (null) is causing the problem.
Setting it to undefined manually fixed the issue in my case
Reported to youtrack: https://youtrack.jetbrains.com/issue/KT-22293
t

Tristan Caron

01/15/2018, 4:16 PM
Whoua so efficient, thanks a lot.
View count: 2