https://kotlinlang.org
Join Slack
Hey guys, any way to use collectAsStateWithLifecycle on Compose Multiplatform?
q

Qamar A. Safadi

almost 2 years ago
Hey guys, any way to use collectAsStateWithLifecycle on Compose Multiplatform?
q
e
  • 2
  • 1
  • 957
Can kover be configured to exclude all generated classes under `build` directories?
l

Lukasz Kalnik

over 2 years ago
Can kover be configured to exclude all generated classes under
build
directories?
đź‘€ 1
l
p
j
  • 3
  • 12
  • 957
I'm getting when applying the Kotlin Multiplatform plugin as well as the Android library plugin… ```...
c

CLOVIS

over 2 years ago
I'm getting when applying the Kotlin Multiplatform plugin as well as the Android library plugin…
Could not create an instance of type org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget.
> Could not generate a decorated class for type KotlinAndroidTarget.
   > com/android/build/gradle/api/BaseVariant
The error message doesn't help me at all, where should I look for to fix this?
c
m
  • 2
  • 19
  • 955
I'm trying to convert a long amount in euro cents to a readable value. I'm not European and I see c...
c

Colton Idle

over 3 years ago
I'm trying to convert a long amount in euro cents to a readable value. I'm not European and I see conflicting information on this. Here is my ext func
fun Long.euroCentsToString(): String {
    val format = NumberFormat.getCurrencyInstance()
    format.maximumFractionDigits = 2
    format.currency = Currency.getInstance("EUR")

    return format.format(this/100)
}
If I call
849999L.euroCentsToString()
I get a result of
€8,499.00
I thought what I'd get is
€8.499,99
So Basically three issues: 1. I thought europeans use
.
to separate thousands from hundreds 2. I thought europeans use
,
to designate the start of fractional (cents) 3. I thought I'd see 99 as the cents and not 00.
c
t
e
  • 3
  • 37
  • 954
how would i check if a float number has any non-zero decimal places 1f vs 1.2f
l

liminal

over 6 years ago
how would i check if a float number has any non-zero decimal places 1f vs 1.2f
l
h
n
  • 3
  • 6
  • 953
I'm having an issue getting gradle to build a KMM app. Targeting Android, Desktop, Server. Whenever ...
b

Brandon Chapman

about 1 year ago
I'm having an issue getting gradle to build a KMM app. Targeting Android, Desktop, Server. Whenever I add
sqldelight
plugin to the
composeApp
build.gradle.kts
it spits out this error:
Using 'compilerOptions(KotlinCommonCompilerOptions.() -> Unit): Unit' is an error. Kotlin target level compiler options DSL is not available in this release!
b
a
  • 2
  • 22
  • 952
Hey everyone. I've gotten my Kotlin Multiplatform running on an iOS app. However, a couple seconds a...
m

Mychael Koelfat

over 2 years ago
Hey everyone. I've gotten my Kotlin Multiplatform running on an iOS app. However, a couple seconds after running the app, it crashes, giving the error
Function doesn't have or inherit @Throws annotation and thus exceptions isn't propagated from Kotlin to Objective-C/Swift as NSError.
If I understand correctly, because Kotlin has no concept of checked exceptions, where Swift only has checked errors. Though I do not understand how I fix this, the documentation doesn't make that too clear for me. Does anyone know how to fix this?
m
h
k
  • 3
  • 3
  • 952
What is a good way to schedule a repeating task in a platform agnostic way? ```fun main() = runBlock...
e

Exerosis

almost 3 years ago
What is a good way to schedule a repeating task in a platform agnostic way?
fun main() = runBlocking {
    val component = Component {
        var a = 0; var b = 0
        every(50.milliseconds) {
            if (it % 20 == 0) println("A: ${a++}")
        }
        every(1.seconds) {
            println("B: ${b++}")
        }
    }
    component.enable()
    delay(50.seconds)
    println("Done!")
}
context(Toggled) @Base
suspend fun every(period: Duration, block: suspend (Int) -> (Unit)) {
    simultaneously {
        var i = 0
        while (isActive) {
            block(i++)
            delay(period)
        }
    }
}
The problem with this is that over time the two tasks get way out of sync: A: 47 B: 49 After 50 seconds
e
f
+4
  • 6
  • 14
  • 950
I have a `LiveData` of type `MutableLiveData<MutableList<User>>`. I have an issue. If ...
n

nilTheDev

almost 4 years ago
I have a
LiveData
of type
MutableLiveData<MutableList<User>>
. I have an issue. If I update the
value
by another
MutableList<User>
the changes are emitted to the observers. However, if I simply add other elements to the
MutableList<User>
, that is already initialised in the
LiveData
, the changes are not emitted. Here is what I am doing...
//other codes 
private val _users: MutableLiveData<MutableList<User>> = MutableLiveData<MutableList<User>>()

init {
    _users.value = mutableListOf<User>()
}

val uiScope = CoroutineScope(Dispatchers.Main + Job())

fun loadUsers(){
    uiScope.launch{
        // this works perfectly
        _users.value = fetchUsers() as MutableList<User>
        // this doesn't work... no idea why
        _users.value.addAll(fetchUsers())
    }
}

suspend fun fetchUsers(): List<User>{
    return withContext(<http://Dispatchers.IO|Dispatchers.IO>){
        //fetch users asynchronously
    }
}
This is just an emulation of the actual program. That actual code is not that trivial.
n
d
+2
  • 4
  • 8
  • 950
Anyone using latest XCode 15 beta 5? Was having issues so created new project using KMM plugin and ...
j

John O'Reilly

almost 2 years ago
Anyone using latest XCode 15 beta 5? Was having issues so created new project using KMM plugin and see same issue when building in XCode.
j
  • 1
  • 5
  • 947
Previous414243Next

kotlinlang

A modern programming language that makes developers happier.

Powered by