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

    lewik

    10/16/2017, 4:20 PM
    Trying to use Vue.js and kotlin, problem with vuex state. Vuex modifies objects in state, so I need to use state without any changes (adding functions) in it. I am looking for
    external
    declarations, that will allow to work with plain js objects and arrays without adding anything to js code. Allow to use js arrays in kotlin - iterate and so on.
    k
    k
    • 3
    • 7
  • n

    nomad

    10/16/2017, 4:50 PM
    hm, i am trying to set up a dependency on a published jar that has only data classes, but my gradle build does not seem to recognize the types, do I need to publish the module differently from a normal kotlin dependency?
    b
    • 2
    • 3
  • l

    lewik

    10/17/2017, 8:17 AM
    How to use ArrayList outside of kotlin, in the js? I am unable to call
    get
    , external class should help?
    k
    • 2
    • 11
  • n

    nomad

    10/17/2017, 8:52 AM
    I have a big kotlin project, with a module that has only dataclasses, this module I want to use for both my other kotlin modules, and my javascript module, but I cannot apply both the kotlin plugin and the kotlin2js plugin at the same time, and a simple "compile (':project')" dependency just leads to resolution failure in gradle. How do I go about having a shared module between my kotlin server and my kotlinjs frontend?
    k
    u
    g
    • 4
    • 15
  • d

    Daniel Illescas

    10/17/2017, 10:50 AM
    <script src=“/Users/Daniel/Documents/IntelliJ IDEA/EverythingKT/node_modules/kotlin/kotlin.js” charset=“UTF-8"></script>
    	<script src=“/Users/Daniel/Documents/IntelliJ IDEA/EverythingKT/node_modules/kotlin/kotlin.meta.js” charset=“UTF-8"></script>
    k
    • 2
    • 3
  • d

    Daniel Illescas

    10/17/2017, 11:04 AM
    so I can use it directly into a page
    k
    b
    • 3
    • 31
  • m

    mmaillot

    10/17/2017, 11:45 AM
    Do you know a library like react but with Kotlin ?
    k
    l
    +3
    • 6
    • 14
  • k

    karelpeeters

    10/17/2017, 4:55 PM
    Is there a way to make stacktraces work with source maps? I do get the line the error was thrown on originally in symbol-version, but the stacktraces show the js line numbers.
    k
    • 2
    • 15
  • v

    verachadw

    10/18/2017, 5:00 AM
    Hi, guys. I just create a Firebase cloud function using KotlinJS and it's look quite promising to JS newbie like me. I implement all the business logic in Kotlin file and covered it by Spek. The problem is for the function that involved with Firebase library. I'm not sure how to start testing with it. Any idea?
    b
    b
    • 3
    • 5
  • a

    Aetet

    10/18/2017, 5:03 PM
    Is there any support for deferred loading for kotlin-js? It's important feature for big scale kotlin projects.
    b
    t
    • 3
    • 7
  • d

    Danilo

    10/19/2017, 5:57 PM
    I tried to use ts2kt from the definatelytyped but ts2kt fails
    b
    • 2
    • 2
  • t

    thesheps

    10/19/2017, 6:29 PM
    Am a massive fan of the language and would love to get started, just a little confused as to my starting point. Ta!
    b
    • 2
    • 1
  • t

    thesheps

    10/19/2017, 7:20 PM
    do i have to go down the gradle route?
    b
    • 2
    • 1
  • s

    Slackbot

    10/20/2017, 11:33 PM
    This message was deleted.
    k
    p
    • 3
    • 2
  • m

    michael salmon

    10/25/2017, 9:40 AM
    ok sorry maybe to clarify, i mean has anyone done this already? i want to still leverage es6 for a bit longer but want to share model data since that is exactly what my server should send from the defined endpoints. i think using the rest of the framework, after reviewing the thinkter demo, would be problematic for my frontend web-developers right now
    b
    • 2
    • 1
  • g

    gaetan

    10/25/2017, 10:57 AM
    By default gradle kotlin-dce-js plugins runs on both main and test code. Is there a reason to include tests code?
    k
    i
    • 3
    • 13
  • n

    nomad

    10/25/2017, 2:33 PM
    how do I declare an external class on a namespace? Do I need to create a package for it or is there some other way?
    k
    • 2
    • 22
  • j

    jasper

    10/26/2017, 5:02 AM
    Compiled code references Kotlin.wrapFunction, but this does not resolve
    :youtrack: 1
    k
    • 2
    • 4
  • h

    hiperbou

    10/27/2017, 12:29 PM
    Hello, I'm using Kotlin in Nativescript and I was having a problem with garbage collection. I have made a simple example to reproduce this issue. In the example, accessing to the kotlin library and forcing gc (It happens also without forcing it) makes the app hang and use ~100% of cpu. I don’t know if it could be a v8 issue or a kotlin.js problem. I would like some advice on how to solve it, because this is making my app unresponsive during undetermined time when a garbage collection happens. Here is a link to the project, It should be visible using and emulator, and clearly a problem in a real device: https://drive.google.com/open?id=0Bx_IBINpIoEKcmtHbEdiLUdoU2c
    b
    • 2
    • 3
  • u

    uliluckas

    10/29/2017, 12:30 PM
    BTW, what's the plan for JB with JS support? I see many basic, language breaking bugs and slow progress compared to other compiler backends.
    k
    u
    • 3
    • 16
  • g

    gildor

    10/31/2017, 1:59 AM
    If we are talking about issues. Yesterday I played with Firebase Functions and Kotlin. I’ve used Kotlin JS to write Firebase Functions (available only as node.js library for now) And found a very strange error on Firebase App initialisation when tried to use firebase-admin library. It crashed on runtime because of undefined INTERNAL field And I have this problem only If I use Kotlin module declaration
    @file:JsModule("firebase-admin")
    but not if I manually define
    require
    function and request module. After some investigations I’ve found a problem and the reason is not my code or library. firebase-admin written in typescript and way how TS defines classes and way how kotlin use them this is the problem. I could reproduce it on minimal example: this is a typescript class:
    class Greeter {
        greeting: string;
        constructor(message: string) {
            this.greeting = message;
        }
        greet() {
            return "Hello, " + this.greeting;
        }
    }
    Compiled to JS:
    var Greeter = /** @class */ (function () {
        function Greeter(message) {
            this.greeting = message;
        }
        Greeter.prototype.greet = function () {
            return "Hello, " + this.greeting;
        };
        return Greeter;
    }());
    So if you use this code in a straitforward way everything is fine:
    var greeter = new Greeter("world");
    console.log(greeter.greet()); //Hello, world
    But Kotlin in generated JS code caches object instance functions to variable and call them using this variable (I think to reduce generated code size). And this is the problem for code above. You can reproduce such problem in pure JS:
    var greeter = new Greeter("world");
    var greet = greeter.greet;
    console.log(greet); // [Function] -- so greet is function
    console.log(greeter.greet()) // Hello, world -- works fine
    console.log(greet()); // Hello, undefined -- undefined
    So instead of reference to instance function we cached prototype function. Actually it means that Kotlin JS not compatible with TypeScript and some other pre-ES6 class implementations. Maybe I missed something, I do not work with JS for a long time and not familiar with TS. I can build later some more self containing example and create an issue.
    k
    • 2
    • 17
  • g

    gildor

    10/31/2017, 9:19 AM
    I have one more question about node.js (particularly about common.js modules) and Kotlin. To declare Firebase Function you have to declare module for this function like:
    module.exports.myFunctionName = functions.https.onRequest(myFunction)
    //instead of https.onRequest can be other function builder
    So looks like I can just declare top level public property with this firebase function builder:
    val myFunctionName =  functions.https.onRequest(myFunction)
    Generated code looks like:
    (function (_, Kotlin, $module$firebase_functions) {
      'use strict';
      var println = Kotlin.kotlin.io.println_s8jyv4$;
      var Unit = Kotlin.kotlin.Unit;
      function myFunctionName$lambda() {
        println('Triggered!');
        return Unit;
      }
      var myFunctionName;
      Object.defineProperty(_, 'myFunctionName', {
        get: function () {
          return myFunctionName;
        }
      });
      myFunctionName = $module$firebase_functions.https.onRequest(myFunctionName$lambda);
      Kotlin.defineModule('index', _);
      return _;
    }(module.exports, require('kotlin'), require('firebase-functions')));
    So, Kotlin defines propery in module.exports, looks like valid way and can be used if you run
    module.exports.myFunctionName()
    But unfortunately this approach doesn’t work with firebase functions, because defined property is not in modules list. This is reproduction of this behaviour in JS:
    var myFunctionName = function() { console.log("Triggered") }
    Object.defineProperty(module.exports, 'doSomething', {
       get: function () {
         return myFunctionName;
       }
    });
    
    console.log(module.exports.doSomething); // [Function: myFunctionName] -- looks like everything is fine
    console.log(module.exports) // {} -- but modules are empty
    module.exports.doSomethingModule = myFunctionName // Declare another module directly
    console.log(module.exports.doSomethingModule); // [Function: myFunctionName] -- same result as for module.exports.doSomething
    console.log(module.exports) // { doSomethingModule: [Function: myFunctionName] } -- but now module is visible in list of all modules
    So, looks like Firebase get list of registered modules from module.exports. I understand that it’s specific case, but maybe it can be somehow resolved without manual module registration using
    external val module: dynamic
    k
    n
    • 3
    • 8
  • r

    redrield

    11/03/2017, 3:30 AM
    Happens with
    create-react-app
    with the kotlin flag, and
    create-react-kotlin-app
    .
    b
    • 2
    • 1
  • k

    karelpeeters

    11/03/2017, 9:09 AM
    What does the
    Long
    represent? Miliseconds since epoch?
    h
    s
    • 3
    • 12
  • b

    bashor

    11/03/2017, 5:21 PM
    Thread for https://kotlinlang.slack.com/archives/C0B8L3U69/p1509723097000694
    d
    • 2
    • 10
  • d

    Deactivated User

    11/04/2017, 12:54 AM
    By fail I mean that it compiles, but generates wrong code using a javascript identifier:
    /home/travis/build/soywiz/kzlib/kzlib/js/build/node_modules/kzlib-js.js:2169
        GZIPInputStream.call($this, in, Inflater_init_3(15 + 16 | 0), size, close_in);
                                    ^^
    SyntaxError: Unexpected token in
        at createScript (vm.js:80:10)
        at Object.runInThisContext (vm.js:139:10)
        at Module._compile (module.js:599:28)
    ...
    Fixed here renaming in to i: https://github.com/soywiz/kzlib/commit/a66b8cd319b36237364bcbc26a36f6a54709f963
    b
    • 2
    • 2
  • p

    pabl0rg

    11/04/2017, 2:56 PM
    https://kotlinlang.org/docs/reference/javascript-dce.html
    j
    n
    • 3
    • 5
  • d

    Deactivated User

    11/05/2017, 11:44 PM
    https://kpspemu.github.io/kpspemu-demo/0.2.5/#samples/TrigWars.zip <-- first demo running 🙂
    👍 1
    🎉 2
    k
    s
    • 3
    • 7
  • d

    Deactivated User

    11/05/2017, 11:45 PM
    BTW it is possible to get the javascript native name of a variable and of a method? I will need it to generate code at runtime here: github.com/kpspemu/kpspemu/tree/master/dynarek
    k
    • 2
    • 4
  • g

    Greg Stepniewski

    11/08/2017, 7:09 AM
    Is there anything in the kotlin-wrappers? I’m using react, reactdom and extensions
    g
    • 2
    • 3
Powered by Linen
Title
g

Greg Stepniewski

11/08/2017, 7:09 AM
Is there anything in the kotlin-wrappers? I’m using react, reactdom and extensions
g

gildor

11/09/2017, 12:19 PM
I don't know such wrappers. But Kotlin team announced that they will release pure Kotlin networking lib that can be used on any platform including JS. But you can easily use any JS API with the same (not exactly the same, tho) way as Kotlin JVM uses Java APIs
React itself doesn't provide any networking APIs or libraries, as I know (kotlin-native does)
Of course, you can use any JS lib for that, bit my 2 cents, that better for now to write own small Kotlin wrapper for XMLHttpRequest, you can even use coroutines for that.
View count: 6