Grantas33
04/25/2020, 5:28 PMit.json().await().unsafeCast<CommonDateTime>()
CommonDateTime:
expect class CommonDateTime(millis: Long) {
fun getYear(): Int
}
However, calling getYear()
function on a casted instance yields an error: TypeError: is not a function
(since unsafeCast
just uses dynamic JS values). Is there an alternative to unsafeCast
that would actually create the objects from JSON so that I could call its instance methods?Franco
04/25/2020, 11:04 PMkotlin-wrapper
libraries and now I'm experiencing a few issues:
1. kotlinx.css
can't be found, but when checking the code in Github the package name doesn't seem to have changed. Does anyone know what happened here?
2. Library dependencies can't be accessed as before and now I have to add them explicitly in my build.gradle.kts
, e.g., kotlin-react-dom
uses kotlin-extensions
and I could access the latter without adding it in my build file, but now I can't unless I do add it. Was this on purpose or an issue of changing the build files to kts?
@turansky I saw that the latest commits are mostly yours so you might know why these things are happening.Philipp Smorygo [JB]
04/28/2020, 12:32 AM...getInstance()
fields?Wolf Logan
04/28/2020, 6:04 PMgradle build
immediately after a gradle clean
, but if I then make a change to any Kotlin code in the JS source set, the next gradle build
will fail.Sean Keane
04/29/2020, 11:37 AM//COMMON CODE
class CredentialsManagerTest: BaseTest() {
@Test
fun runTest() = runTest {
fail()
}
}
expect abstract class BaseTest(){
fun <T> runTest(block: suspend CoroutineScope.() -> T)
}
//JS ACTUAL
actual abstract class BaseTest actual constructor() {
actual fun <T> runTest(block: suspend CoroutineScope.() -> T) {
}
}
The test runs in JS
> Task :common:compileKotlinJs UP-TO-DATE
> Task :common:jsMainClasses UP-TO-DATE
> Task :common:compileTestKotlinJs UP-TO-DATE
> Task :common:compileDevelopmentTestKotlinJs UP-TO-DATE
> Task :common:jsTestClasses UP-TO-DATE
> Task :common:jsBrowserTest
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See <https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings>
BUILD SUCCESSFUL in 14s
I have it setup to use Firefox as the test browser
browser() {
webpackTask() {
mode = org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.Mode.DEVELOPMENT
sourceMaps = true
}
testTask {
useKarma { useFirefox() }
enabled = true
}
}
But the test passes?? It runs the test in the browser and goes green. I cant seem to make it fail? Am I missing something?
This is in a Multiplatform Project and has an Android Component also.Chilli
04/29/2020, 3:49 PMChilli
04/29/2020, 5:14 PMGrantas33
04/29/2020, 6:53 PMNick Williams
04/29/2020, 11:30 PMSean Keane
04/30/2020, 11:54 AMv79
04/30/2020, 12:09 PMFoso
05/01/2020, 9:47 AMiseki
05/04/2020, 5:27 AMclosure$handler
is not a function... But my handler
is a lambda... What's happend. Thank you
My code is pasted on: https://paste.ubuntu.com/p/TspvByyRNP/gbaldeck
05/04/2020, 11:20 PMrnentjes
05/05/2020, 11:42 AMandrewreitz
05/05/2020, 10:07 PMspierce7
05/06/2020, 3:01 PMiari
05/07/2020, 8:11 PMSebastien Leclerc Lavallee
05/08/2020, 4:44 AMiari
05/08/2020, 6:09 PMRComponentClassStatics
and RStatics
and some 'documentation' here:
https://github.com/JetBrains/kotlin-wrappers/blob/master/kotlin-react/src/main/kotlin/react/React.kt#L63-L77
So i tried implementing it like this:
external interface ErrorBoundaryState : RState {
var error: Throwable?
}
class ErrorBoundary : RComponent<RProps, ErrorBoundaryState>() {
init {
state.error = null;
}
override fun componentDidCatch(error: Throwable, info: RErrorInfo) {
//super.componentDidCatch(error, info)
//state.error = error
//state.errinfo = info
console.log("ErrorBoundary encountered error:", error)
}
override fun RBuilder.render() {
state.error?.let { e ->
styledDiv {
h3 {
+"Something went wrong"
}
p {
+e.toString()
}
}
} ?: props.children()
}
companion object : RStatics<RProps, ErrorBoundaryState, ErrorBoundary, Nothing>(ErrorBoundary::class) {
override var getDerivedStateFromError: ((Throwable) -> ErrorBoundaryState?)?
get() = {
object : ErrorBoundaryState {
override var error: Throwable?
get() = it
set(value) {}
}
}
set(value) {
}
}
}
However, this fails and nothing is rendered, and I get this error:
Warning: ErrorBoundary: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.
in ErrorBoundary
in Unknown
so how is this done properly?Grantas33
05/08/2020, 10:08 PMCan't find variable: PushManager
, since safari does not support PushManager API. I've declared an external class PushManager
with required methods in my kotlin.js app. Inside the compiled .js bundle there is a variable assignment to a PushManager class (like a typealias), and that is the reason of the error on safari. Is there a way I could prevent this?andrewreitz
05/09/2020, 11:58 AMbuild/js
?Marian Schubert
05/09/2020, 5:15 PMaerb
05/09/2020, 6:45 PMmkosm
05/09/2020, 6:59 PMCastReceiverContext
by calling cast.framework.CastReceiverContext.getInstance()
. In order to do that, I've done this:
external object cast {
var framework: Framework
}
external object Framework {
var CastReceiverContext: CastReceiverContextStatic
}
external open class CastReceiverContextStatic() {
fun getInstance(): CastReceiverContext
}
// access it using:
val context = cast.framework.CastReceiverContext.getInstance()
This works, but I feel like there is a better way to do this. Is there?iari
05/10/2020, 4:39 PMwindow.fetch
(... or any api available in kotlin.js), or do i really just have to configure my requests 'manually' with these weak types?iari
05/10/2020, 8:57 PMiari
05/10/2020, 9:35 PMonChangeFunction
the event.target is of type EventTarget?
which has no value field.andrewreitz
05/11/2020, 12:15 AMrequire('fs').writeFile
turansky
05/11/2020, 5:01 PMval messagePort:MessagePort = ...
messagePort.onmessage = { event -> println(event) }
dazza5000
05/11/2020, 5:02 PM