https://kotlinlang.org
Join Slack
How can I convert this to kotlin dsl? ```include ':library' project(':library').projectDir = new Fil...
j

jean

over 5 years ago
How can I convert this to kotlin dsl?
include ':library'
project(':library').projectDir = new File(settingsDir, '../MyLibrary/library')
I don’t find any info on how to set the project path with kotlin
j
o
  • 2
  • 24
  • 292
Is it possible to disable Ktor client keep-alive?
e

eirikb

almost 6 years ago
Is it possible to disable Ktor client keep-alive?
e
e
c
  • 3
  • 3
  • 292
Using the new Compose Type-Safe Navigation. How can you check if the currentBackstackEntry is a spec...
t

Tom Truyen

over 1 year ago
Using the new Compose Type-Safe Navigation. How can you check if the currentBackstackEntry is a specific route?
val backStackEntry by navController.currentBackStackEntryAsState()

LaunchedEffect(backStackEntry) {
    val route: Route = backStackEntry?.toRoute() // Always returns null, even when backStackEntry route is not null
}
I currently am using a workaround using the qualified name:
val route = backStackEntry?.destination?.route == Screen.Profile::class.qualifiedName
Though I would prefer a better method. I personally would expect that if I do toRoute() I could do a check like
route is Screen.Profile
but since toRoute always returns null this check will always fail The way I have build my routes:
sealed interface Screen {
    sealed interface Auth: Screen {
        @Serializable
        data object Login : Auth

        @Serializable
        data object Register: Auth
    }

    @Serializable
    data object Profile: Screen
}
t
c
k
  • 3
  • 5
  • 291
Often I'm in a situation where I want to wrap a code like this ```fun someFun(): Int { // ... } `...
d

David Kubecka

over 1 year ago
Often I'm in a situation where I want to wrap a code like this
fun someFun(): Int {
   // ...
}
with some context-adding function. For instance
binding
from kotlin-result:
fun someFun(): Int = binding {
   // ...
}
Unfortunately, this violates two rules: standard:function-signature and standard:multiline-expression-wrapping. I would like to avoid the reformat since it increases the indentation of the whole function body, thereby unnecessarily crippling git history. Since both these rules might be useful in different contexts I hesitate to simply switch them both off. Would it be possible to relax (possibly optionally - based on a setting) these rules in this situation? I.e. allow the function block to start on the same line as the function header.
d
p
e
  • 3
  • 9
  • 291
I'm getting a `kotlinx.serialization.SerializationException` but the error doesn't make sense. This ...
c

Chris B

over 1 year ago
I'm getting a
kotlinx.serialization.SerializationException
but the error doesn't make sense. This is the error:
Exception in thread "main" kotlinx.serialization.SerializationException: Serializer for subclass 'GridClueSelection' is not found in the polymorphic scope of 'Selection'.
Check if class with serial name 'GridClueSelection' exists and serializer is registered in a corresponding SerializersModule.
To be registered automatically, class 'GridClueSelection' has to be '@Serializable', and the base class 'Selection' has to be sealed and '@Serializable'.
except
GridClueSelection
is Serializable, and
Selection
is sealed and Serializable.
c
m
j
  • 3
  • 11
  • 291
Hi all, I'm having a problem with the Kotest IntelliJ plugin where the green play buttons aren't dis...
p

phil-t

almost 2 years ago
Hi all, I'm having a problem with the Kotest IntelliJ plugin where the green play buttons aren't displaying next to the tests. Are there any options in IntelliJ I would need to change for this to work? This is after getting a new Macbook, and it worked on the old Macbook so I don't know what would have changed to cause this problem with the plugin
p
k
  • 2
  • 7
  • 291
After modularizing a project using a ksp processor I get the following error ```A problem occurred c...
j

jean

about 2 years ago
After modularizing a project using a ksp processor I get the following error
A problem occurred configuring project ':logic'.
> Could not create task ':logic:compileKotlinIosArm64'.
   > Task with name 'kspCommonMainKotlinMetadata' not found in project ':logic'.
logic
is the name of my module. I did work all good when I had a single module structure. I did add the plugins the same way it’s done hete https://github.com/google/ksp/blob/main/examples/multiplatform/workload/build.gradle.kts Any idea how I can fix this?
j
t
  • 2
  • 10
  • 291
Navigation Question: when navigating to a route that takes some parameters (i.e. a route like `path/...
b

Bradleycorn

almost 4 years ago
Navigation Question: when navigating to a route that takes some parameters (i.e. a route like
path/to/products/{cateegory}/{id}
), I don’t want to just hard code strings throughout my application (like:
navController.navigate("path/to/products/shirts/1234")
. If that route ever changes, I have to find and update it throughout my application. I’m curious what sort of architecture others have used to address this? My current solution in the 🧵
b
z
+4
  • 6
  • 14
  • 291
how to disable this TRACE logging? I didn't configured any logging for ws
a

Andrey Tabakov

almost 3 years ago
how to disable this TRACE logging? I didn't configured any logging for ws
a
c
  • 2
  • 6
  • 291
How do you use the `view model` for Kotlin Multiplatform(`Desktop, Android`) projects? In Android, t...
v

vnycall74

almost 3 years ago
How do you use the
view model
for Kotlin Multiplatform(
Desktop, Android
) projects? In Android, the view model extends ViewModel (Android), but that's a natural thing to say, Desktop hasn't ViewModel. So I can't use the common view model. Additionally, I think some things, but It looks not good... A. Inject view model of each platform
Window(onCloseRequest = { // Do something }, title = "Test") {
    val testViewModel by inject<TestViewModel>(TestViewModel::class.java)

    TesetScreen(
        user = testViewModel.user,
        testState = testViewModel.testState.collecAsState().value,
        testAction = testViewModel::testAction
    )
    
    DisposableEffect(Unit) {
        onDispose { 
            testViewModel.onCleared()
        }
    }
}
B. Use use-case direct in the Composable Screen
Window(onCloseRequest = { // Do something }, title = "Test") {
    val getUserUseCase by inject<GetUserUseCase>(GetUserUseCase::class.java)
    val getTestState by inject<GetUserUseCase>(GetUserUseCase::class.java)

    TesetScreen(
        user = testViewModel.user,
        testState = getTestState().collecAsState().value,
        testAction = { doSomething() }
    )
}
C. Don't use the view model... What do you think about the above logic and how do you design architecture KMP?
v
m
  • 2
  • 2
  • 291
Previous243244245Next

kotlinlang

A modern programming language that makes developers happier.

Powered by