janvladimirmostert
02/14/2021, 5:17 PMclass POST(
val uri: String,
val json: String,
) {
suspend fun <T> submit(): T {
return window.fetch(
input = "${ENV.server}$uri",
init = RequestInit(
body = json,
method = "POST",
headers = json("content-type" to "application/json; charset=UTF-8"),
)
).await().json().await().unsafeCast<T>()
}
}
@JsExport
@ExperimentalJsExport
object Data {
suspend fun getColumns(request: ColumnRequestVO): ColumnResponseVO {
return POST(uri = "/columns", json = request.toString()).submit<ColumnResponseVO>()
}
}
Declaration of such kind (suspend function) cant be exported to JS
Jackson Bean
02/16/2021, 12:09 AMMarc Knaup
02/18/2021, 5:19 PM-Xir-property-lazy-initialization
.
With -Xir-per-module
I need to know if a certain module was already loaded. The only which comes to mind is to set a global variable when loading that module, and check if that variable set from other modules.Big Chungus
02/18/2021, 5:54 PMjvmusin
02/18/2021, 6:41 PMreact-tooltip
to my project. https://www.npmjs.com/package/react-tooltip
It has some static methods like ReactTooltip.show(element)
How can I add these methods with the new IR compiler?
I used a workaround to avoid problems with default
described here: https://github.com/anton-bannykh/web-app-react-kotlin-js-gradle/blob/IR-fixes/src/main/kotlin/ReactPlayer.kt
This thread is related: https://github.com/JetBrains/kotlin-wrappers/issues/361
And this is my code for ReactTooltip:
import react.RClass
import react.RProps
@JsModule("react-tooltip")
@JsNonModule
external object ReactTooltip {
val default: RClass<ReactTooltipProps>
}
external interface ReactTooltipProps : RProps {
var id: String
var type: String
}
I tried to add this method as an instance method on object ReactTooltip
, but JS says it's not a function.
I also tried to add it like val show: (target: Element) -> Any = definedExternally
, but it doesn't seem to work too.
Any suggestions?Etienne
02/18/2021, 10:15 PMFlow.single()
is broken in kotlin-js? Makes me think I'm probably not understanding correctly what's going on.spand
02/23/2021, 9:05 AMnew
on ?
class KotlinClass extends ExternalClass {
constructor(p1 : Context) : super(p1) {
}
}
When I pass KotlinClass::class.js
it will pass the KotlinClass
in javascript land.. but the super
call is placed in the function KotlinClass_init()
which seems to ever only be called from Kotlin.
I tried getting a reference to KotlinClass_init
but doing ::KotlinClass
in kotlin land doesnt work either. I think its because it is wrapped in a function leading to a loss of the this
value. Ultimately I cannot see how javascript can ever new a Kotlin class that needs to pass parameters to its super constructor.
It seems to me that it is a compiler flaw that the kotlin constructor body is not placed in the native javascript constructor instead of this init function.your_rubicon
02/25/2021, 5:17 AMSebastian Aigner
02/25/2021, 1:38 PM[](https://kotl.in/jsirsupported)>
Jurriaan Mous
02/25/2021, 3:11 PM"types": "kotlin/shared.d.ts"
field in the package.json
. Without that field TypeScript did not detect the types of the module in the project. I for now added the field manually with:
compilations["main"].packageJson {
customField("types", "kotlin/shared.d.ts")
}
Did I miss a setting or should I report an issue to YouTrack?Harald Pehl
02/26/2021, 2:54 PMgaetan
02/28/2021, 6:36 PMKotlin.defineModule
js function when using DCE?Animesh Sahu
03/01/2021, 3:54 PM@JvmSynthetic
in K/JS?Big Chungus
03/03/2021, 10:34 AMsteamstreet
03/08/2021, 7:14 PM"Couldn't find package "…-jsIr@1.0.1" required by "…-jsLegacy@1.0.1 on the "npm" registry."
even though I have them both configured with js(BOTH) {}
Christoph Hock
03/08/2021, 7:53 PMval iframeDocument = element.contentWindow?.document
iframeDocument?.body?.addEventListener("mouseup", callback = { event ->
val target = event.target?.unsafeCast<HTMLElement>()!!
})
andrea.santurbano
03/09/2021, 9:57 AMIR
).
The produced code seems not do depend to Kotlin as it contains internally all the required data structures and they’re not compatible with the Kotlin.js library
Can somebody help me or point to some useful resource that explain how to use kotlin-to-js compiled code into pure js applications?Sebastian Aigner
03/09/2021, 2:24 PMDmitry Romanov [JB]
03/11/2021, 8:42 AMAshish Kumar Joy
03/11/2021, 2:08 PMShabinder Singh
03/12/2021, 11:58 AMput(key="data",*ArrayBuffer)*
but put only accepts JsonElement , so how to do this? as JS Function expects an ArrayBuffer there...
Any Help is Appreciated!Shabinder Singh
03/12/2021, 5:06 PMID3Writer is not a constructor
crummy
03/13/2021, 9:43 AMMap<X, Y>
. I can't export List
or Collection
either but those I can map to Array
- is there an equivalent solution for `Map`s?crummy
03/13/2021, 9:16 PMkotllin.js
from kotlin.js.promise
(see KT-43632) and I guess I can hack up some Gradle to do this but wondered if there was a convention or tool for this.Derek Ellis
03/14/2021, 2:43 AMExecution failed for task ':common:jsBrowserDevelopmentWebpack'.
> Module 'fs' not found
Derek Ellis
03/15/2021, 3:18 AMSqlJs
object which I believe is supposed to be bundled by webpack from the sql.js
package. I've tried a handful of different custom webpack config changes but nothing seems to help.Peter Ertl
03/17/2021, 3:19 PMwillyrs
03/17/2021, 8:40 PMiseki
03/18/2021, 6:11 AMРолан
03/18/2021, 6:32 AMРолан
03/18/2021, 6:32 AMBig Chungus
03/18/2021, 8:33 AMРолан
03/18/2021, 9:29 AMBig Chungus
03/18/2021, 9:50 AMРолан
03/18/2021, 9:56 AMBig Chungus
03/18/2021, 10:29 AMРолан
03/18/2021, 10:51 AM