https://kotlinlang.org
Join Slack
Is there an way to mock a function that receives a callback as parameter? For example, assuming that...
i

igorvd

over 6 years ago
Is there an way to mock a function that receives a callback as parameter? For example, assuming that I have an assync operation, and the way to get the result is using an interface as callback. I want to unit test this method, defining responses in this callback. The problem lies in the fact that the callback is declared as anonymous (I will put an example below). Is possible to mock this callback and define its responses using MockK? Here is an example:
class ViewModel {

	fun loadSomeStuff() {
		myObject.asyncOperation(object : Callback {
			//callback methods implementation
		})
	}
}
I know if I change the callback for a parameter in my class, it will be easily mocked. But, in my opinion it doesn't make sense, because it's related to the operation I need in the method. (This example is just for learning purposes, I was trying to teach a colleague about unit tests, and I got stocked in this scenario)
i
h
  • 2
  • 4
  • 1419
If anyone has been looking for a Rich Text editor composable, I ported a Jetpack compose library som...
a

Adam Brown

over 3 years ago
If anyone has been looking for a Rich Text editor composable, I ported a Jetpack compose library someone made to multiplatform compose (w_ith the original authors blessing_) https://github.com/Wavesonics/richtext-compose-multiplatform it's still pretty early, but I'm continuing to work on it.
👏 2
❤️ 4
K 5
👏🏻 1
🎉 8
👏🏾 1
a
j
+2
  • 4
  • 8
  • 1418
```Key "..." was already used. If you are using LazyColumn/Row please make sure you provide a unique...
z

Zoltan Demant

about 3 years ago
Key "..." was already used. If you are using LazyColumn/Row please make sure you provide a unique key for each item.
For crashes like these, is there any work being done to improve the stack traces? I have a billion LazyColumn/Rows in my project, and while the error message explains the issue perfectly, I have zero insight into where it actually happens.
z
a
  • 2
  • 3
  • 1416
I’m getting this after enabling K2 mode > Plugin ‘Kotlin Multiplatform’ wasn’t loaded because it’...
a

aidanvii

over 1 year ago
I’m getting this after enabling K2 mode
Plugin ‘Kotlin Multiplatform’ wasn’t loaded because it’s incompatible with the Kotlin plugin in K2 mode
a
t
+2
  • 4
  • 8
  • 1414
Hello, everyone! What is the best way to generate OpenAPI docs basing on Ktor routings (already writ...
a

aazavoykin

over 2 years ago
Hello, everyone! What is the best way to generate OpenAPI docs basing on Ktor routings (already written)? There`s Ktor OpenAPI Generator (https://github.com/papsign/Ktor-OpenAPI-Generator), but the project seems not very active.
a
c
+3
  • 5
  • 9
  • 1410
How can I align Text and content of OutlinedTextField to CenterVertically?
c

chanjungskim

over 2 years ago
How can I align Text and content of OutlinedTextField to CenterVertically?
c
e
  • 2
  • 7
  • 1406
Is there a way to show a Compose popup or dialog from an Android custom view? We have lots of Androi...
e

Eric Martori

over 3 years ago
Is there a way to show a Compose popup or dialog from an Android custom view? We have lots of Android custom views that we don't have the time to migrate fully to compose, but we are adding new developments in compose gradually. Adding
ComposeView
in the XML works for most cases, but now we have to show a pop window and an alert on user interaction. We have tried creating the
PopupWindow
and
AlertDialog
programmatically and setting the content view as a
ComposeView
with the desired content but we get errors like:
java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from android.widget.PopupWindow$PopupDecorView
So we are thinking that maybe there is a way to launch the alert and popup directly from compose, but don't know how to launch it from inside a custom view without replacing the already working content.
e
m
a
  • 3
  • 18
  • 1405
Exposed supports Jsonb types with postgres database?
w

Wishnuprathikantam

over 4 years ago
Exposed supports Jsonb types with postgres database?
w
j
  • 2
  • 2
  • 1401
```w: Kotlin Multiplatform <-> Android Gradle Plugin compatibility issue: The applied Android Gradle...
j

Joel Denke

over 1 year ago
w: Kotlin Multiplatform <-> Android Gradle Plugin compatibility issue:
The applied Android Gradle Plugin version (8.3.0) is higher 
than the maximum known to the Kotlin Gradle Plugin.
Tooling stability in such configuration isn't tested, please report encountered issues to <https://kotl.in/issue>"

Minimum supported Android Gradle Plugin version: 7.0
Maximum tested Android Gradle Plugin version: 8.2

To suppress this message add 'kotlin.mpp.androidGradlePluginCompatibility.nowarn=true' to your gradle.properties
Really, how can it be that Kotlin plugin is not supporting version of AGP that is 8.3? I am using Kotlin 1.9.23, Gradle 8.6, AGP 8.3, Java 17.
j
g
+2
  • 4
  • 4
  • 1395
Is there any way to disable scroll and clicks on children in a LazyColumn?
u

Utkarsh Tiwari

over 4 years ago
Is there any way to disable scroll and clicks on children in a LazyColumn?
u
a
g
  • 3
  • 5
  • 1392
Previous212223Next

kotlinlang

A modern programming language that makes developers happier.

Powered by