Meherdatta Chepuri
03/10/2023, 1:58 AMAmrJyniat
03/10/2023, 8:03 AMcoroutines-core-native-mt
for KMM project, is it correct that this one makes Coroutine works on IOS as Android? do still I need it in the newest version or the coroutines-core
enough?natpryce
03/10/2023, 8:15 AMexpect
declarations because the DOM API is mapped to interfaces in the JVM platform and classes in the Javascript platform. The DOM objects are provided by factories in both platforms, so my code only needs to use the DOM objects, not instantiate the classes nor implement the interfaces. What should the expect declaration be?AmrJyniat
03/10/2023, 9:28 AMRui Reis
03/10/2023, 10:35 AMSlackbot
03/10/2023, 10:40 AMHovo
03/10/2023, 6:53 PMMeherdatta Chepuri
03/10/2023, 7:47 PMPat Teruel
03/10/2023, 9:28 PMGlobalScope.async
? Or is there an alternative way to do a DispatchQueue.global().async
on KMM?
My problem is, KMM doesn’t have a close-to-native way of Scheduling tasks without freezing the Suspend function. So I had to create a class that’s “invalidatable”, similar to that of the Timer in Swift.
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
class AsyncSchedulerCaller(
delayTime: Long,
suspendFunction: suspend () -> Unit
) {
init {
GlobalScope.async {
delay(delayTime)
if (invalidated) {
println("Invalidated.")
} else {
isRunning = true
suspendFunction()
isRunning = false
}
}
}
var invalidated = false
var isRunning = false
fun invalidate() {
invalidated = true
}
}
The way I use this is I store it in an optional variable and invalidate if it exists and create a new one, e.g.
class SomeClass {
var scheduler: AsyncSchedulerCaller? = null
suspend fun someSuspendFunction() {
runSomeApiCallHere()
scheduler?.invalidate() // this will make sure that the existing scheduled task will not be run
scheduler = AsyncSchedulerCaller(
delayTime = 500, // will run after 500 milliseconds
suspendFunction = {
runSomeOtherApiCallHere()
}
)
}
}
To be honest, it already runs properly in iOS, and the scheduled task seem to run in the background. But I want to understand why it does, else, I might encounter bugs and I wouldn’t know how to fix.
That said, it works in iOS, but I haven’t tested in Android. Would this kind of code be dangerous on the app’s lifecycle in Android?
Thanks for the answers.Harnick
03/11/2023, 12:47 PMFinalize
wasn't the greatest solution when it came to Java's GC, but with KMM supporting more than just Android, is there a better way to destroy a coroutine scope along with its viewmodel?Andrey
03/11/2023, 3:11 PM<https://github.com/darvincisec/o-llvm-binary>
, but perhaps there is something else for KMM ? Any information would be helpfulKoneko Toujou
03/12/2023, 1:33 PMJustin Xu
03/13/2023, 2:09 AMLoginManager
that managers users logging into my app and downloading their data from database, and should be created/destroyed when the user logs in/out. Is there a common design pattern/implementation for this sort of dependency?Varun Sharma
03/13/2023, 7:26 AMTask 'testDebugUnitTest' not found in project
AndreiBogdan
03/13/2023, 11:12 AMSingle
from my native Android app . I have the following:
fun getAssignedBooks(): SingleWrapper<List<String>> {
return singleFromCoroutine {
callAssignedBooks()
}
.subscribeOn(ioScheduler)
.observeOn(mainScheduler)
.wrap()
}
But when I try to do this:
val assignedBooks = SharedBookRepository().getAssignedBooks()
assignedBooks.subscribe()
I get this:
Cannot access 'com.badoo.reaktive.base.Source' which is a supertype of 'com.badoo.reaktive.single.SingleWrapper'. Check your module classpath for missing or conflicting dependencies
Cannot access 'com.badoo.reaktive.single.Single' which is a supertype of 'com.badoo.reaktive.single.SingleWrapper'. Check your module classpath for missing or conflicting dependencies
Any ideas why ? 😞 I'm using RxJava2 in my native Android app, I'd also like to chain the getAssignedBooks()
with other observables and singles using .flatMap()
and such, but not sure how I can do that. And it's been stressing me out for the past hour+Harsh Joshi
03/13/2023, 11:55 AMHarnick
03/13/2023, 3:38 PMBradleycorn
03/13/2023, 9:30 PMassembleMyLibXCFramework
task. So far so good. Here’s how I have it configured:
kotlinArtifacts {
Native.XCFramework("MyLib") {
targets(iosX64, iosArm64, iosSimulatorArm64)
modes(NativeBuildType.DEBUG, NativeBuildType.RELEASE)
linkerOptions = linkerOptions + listOf("-lsqlite3")
}
}
Sooo … Now I want to publish the xcframework via cocoapods (eventually SPM as well, but one thing at a time…). I don’t see how the new DSL to produce the framework works with the existing cocoapods
DSL provided by the native.cocoapods
plugin? Or maybe they don’t work together at all? Can I publish an XCFramework generated with the Experimental DSL using cocoapods? How so?Stan
03/13/2023, 11:22 PM<webpack://doodle-contacts/compileSync/*>
Chrome/Debug Error:
Could not load content for
<webpack://doodle-contacts/compileSync/js/main/productionExecutable/kotlin/jsMainSources/libraries/stdlib/js/src/kotlin/collections/HashSet.kt?fb14>
Fetch through target failed: Unsupported URL scheme; Fallback: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME)
I would like to be able to step through kotlin library code, just like I do with JDK library code.
I think I should be able to look at and step through any kotlin src in commonMain.
But am I trying to do something that cannot be done?
Here is my "most recent"
js(IR) {
browser {
compilations.all {
kotlinOptions {
metaInfo = true
sourceMap = true
sourceMapEmbedSources = "always"
verbose = true
}
}
commonWebpackConfig {
devServer?.`open` = false
devServer?.`port` = 9090
mode = DEVELOPMENT
devtool = EVAL_SOURCE_MAP
sourceMaps = true
showProgress = true
}
}
binaries.executable()
}
}
I added a screen-shot of my debugger in the thread.elect
03/14/2023, 9:50 AMkotlinx-benchmark-runtime:0.4.3
and I'd like the jvmBench
sources to extend the jvmMain
, in order to avoid things as re-declaration of expected classes and so on
In the readme, they simply write (in Groovy script)
Propagate dependencies and output fromsourceSet.main
```dependencies {
benchmarksCompile sourceSets.main.output + sourceSets.main.runtimeClasspath
}```how can I translate that to Kotlin DSL? Looking around at other examples, I tried the following, but without success:
kotlin {
targets {
jvm {
compilations {
val main by getting
val bench by creating {
defaultSourceSet {
dependencies {
implementation(main.compileDependencyFiles + main.output.classesDirs)
}
}
}
}
}
}
}
Håkon Pettersen
03/14/2023, 9:56 AMBrais Gabin
03/14/2023, 10:12 AMbuild.gradle.kts
in all the modules for that reason I want to move all that to a gradle plugin. My problem is how to translate val androidMain by getting
.ChChenna Rao
03/14/2023, 10:49 AMIdan
03/14/2023, 11:19 AMrb90
03/14/2023, 1:04 PMio.ktor.client.HttpClient
. I am using it in a Kotlin Multiplatform project. For this, I followed the tutorial provided here: https://ktor.io/docs/getting-started-ktor-client-multiplatform-mobile.html.
From what I see there, for the HttpClient
I don't need to call .close()
? Because the Ktor docs here https://ktor.io/docs/create-client.html#close-client describe that close needs to be used to free up the resources.
However if I am calling .close()
on my instance of HttpClient
and after that, I am trying a 2nd request with it, I got a crash. I tried that by calling my request function from my iOS client and I run in sth like this: kotlinx.coroutines.JobCancellationException: Parent job is Completed; job=SupervisorJobImpl{Completed}@e50024f0
.
I am using one single instance in my Multiplatform module for the HttpClient
like suggested in the Ktor docs:
Note that creatingSo there is no new instance created for each request. Is that usage correct? Can you please give me here an advice?is not a cheap operation, and it's better to reuse its instance in the case of multiple requests.HttpClient
mohamed rejeb
03/14/2023, 2:53 PMspierce7
03/14/2023, 3:48 PMVitaliy Zarubin
03/15/2023, 5:57 AMPriyanshu Jain
03/15/2023, 8:22 AMHasan Nagizade
03/15/2023, 8:52 AMHasan Nagizade
03/15/2023, 8:52 AMPablichjenkov
03/15/2023, 9:39 AMHasan Nagizade
03/15/2023, 9:40 AMPablichjenkov
03/15/2023, 9:43 AMcompose multiplatform
, for that there are some official experimental templatesHasan Nagizade
03/15/2023, 9:43 AMPablichjenkov
03/15/2023, 9:45 AMHasan Nagizade
03/15/2023, 9:45 AMPablichjenkov
03/15/2023, 9:46 AMHasan Nagizade
03/15/2023, 9:57 AM