Kurt Renzo Acosta
12/06/2019, 9:54 AMclass MyViewModel(private val useCase: UseCase) : ViewModel() {
fun doSomething() {
useCase()
liveData.value = "New Value"
}
}
class MyPresenter(private val myView: MyView, private val useCase: UseCase) : BasePresenter() {
fun doSomething() {
useCase()
myView.updateView("New Value")
}
}
I wanted to extract the common code between them so initially, I created an expected class and wanted something like this:
expect class MyCommonClient(useCase: UseCase) {
fun doSomething() {
useCase()
success("New Value")
}
expect fun success(newValue: String)
}
But then, Expected declaration must not have a body
So I tried out a class:
abstract class MyCommonClient(useCase: UseCase) {
fun doSomething() {
useCase()
success("New Value")
}
abstract fun success(newValue: String)
}
But now, I'm having multiple supertypes
class MyViewModel : ViewModel(), MyCommonClient() <--- Error
Am I running towards a wall or is there any workaround or pattern to achieve something like this?
Thanks in advance!fuddi
12/06/2019, 11:18 AMJoris PZ
12/07/2019, 6:53 PMExecution failed for task ':linkDebugExecutableMingw'.
> Process 'command 'C:\dev\java\openjdk-11.0.2\bin\java.exe'' finished with non-zero exit value 1
Before I throw in the towel and just continue on JVM alone, if anyone would be willing to take a look to see what I could be doing wrong it would be much appreciated. The repo is https://github.com/jorispz/aoc-2019, the project is pretty much standard as generated by IDEA, with the addition of the coroutine depenendencies.Marc Knaup
12/08/2019, 1:05 PMJoey
12/09/2019, 6:43 AMGlobalScope.future
P.S.
Im developing a library for android and iOSribesg
12/09/2019, 11:15 AM@Parcelize
in a multiplatform library, using `expect`/`actual` on @Parcelize
and Parcelable
, but I encounter a very weird error when using the kotlin.android.extensions
plugin on one library: “This class does not have a constructor” on a data class
. Anyone encountered this?Boris Dudelsack
12/09/2019, 12:47 PMRak
12/09/2019, 1:03 PMRak
12/09/2019, 1:03 PMPiasy
12/10/2019, 4:27 AMabstract class ConfEvents {
open fun onPeerJoined(uid: String) {}
}
Here is the generated C header:
struct {
libAvConf_KType* (*_type)(void);
libAvConf_kref_com_piasy_avconf_ConfEvents (*ConfEvents)();
void (*onPeerJoined)(libAvConf_kref_com_piasy_avconf_ConfEvents thiz, const char* uid);
} ConfEvents;
If I compile kotlin code into framework, then ConfEvents
would have a Objective-C interface, then I can extend it and pass it to kotlin.Cristián Arenas
12/10/2019, 7:19 PMfun MyType.newMethod(x: NSSomething) {}
I could call it from iOS with the appropriate type.
But if I add the equivalent in Android, it isn’t callable.gaetan
12/10/2019, 10:49 PMJoey
12/11/2019, 5:10 AMsuspend fun fetchUsers(): List<String> {
val response = client.get<JsonObject> { url("$baseUrl/heartbeat.json") }
val userIds = response.keys.toList()
return userIds
}
Now im trying to implement it in a pure old java project. I enabled the kotlin plugin in this project and created this function:
fun fetchUsersFromKtLib(): List<String> {
val api = HeartbeatApi()
val users = GlobalScope.future { api.fetchUsers() }
return users.get()
}
Now everytime im calling this fetchUsersFromKtLib
function, there is a jank in my UI (a freeze). Im trying to solve this problem for about 3 days now. So far this is the cleanest way i called the function from the kotlin shared library. What can you suggest to avoid any UI freeze? Thanks guys!dambakk
12/11/2019, 8:16 AM1.3.2
) and implemented an iOS dispatcher as explained by @salomonbrys in the kotlinconf workshop. The actual
on the android side works fine, but I get an unresolved reference on the CoroutineDispatcher
import on the ios side. When running the gradle assemble i get an error saying The abi versions don't match. Expected '[17]', found '14'
. Any idea what causes this and how to resolve it?Jan Stoltman
12/11/2019, 9:25 AMMiguel Fermin
12/11/2019, 9:46 PMapp
|
|_ LibA
|
|_ LibB (mpp)
Next thing I have in mind is trying to generate .jar libraries from Kotlin mpp and see if that works
Any ideas would be highly appreciated.saket
12/12/2019, 3:45 AMiosX64("ios")
with targetFromPreset(presets.iosX64, 'ios')
is resulting in a strange error that I can't figure out. I'm already using Xcode 11 (currently downloading 11.3 if that changes anything). Does this look familiar to anyone?
> Task :shared:linkDebugFrameworkIos
error: Invalid record (Producer: 'LLVM8.0.0svn' Reader: 'LLVM APPLE_1_1100.0.33.8_0')
1 error generated.
e: Compilation failed: The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ command returned non-zero exit code: 1.
output:
* Source files:
* Compiler version info: Konan: 1.3.60 / Kotlin: 1.3.60
* Output kind: FRAMEWORK
e: org.jetbrains.kotlin.konan.KonanExternalToolFailure: The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ command returned non-zero exit code: 1.
saket
12/12/2019, 7:08 AMiosX64()
with fromPreset(presets.iosX64)
is fine, but the actual error is coming from these lines:
framework {
// Disable bitcode embedding for the simulator build.
if (!buildForDevice) {
embedBitcode("disable")
}
}
saket
12/12/2019, 7:08 AMKonstantin Tskhovrebov
12/12/2019, 3:48 PMProperty Wrapper
https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID617trickybits
12/12/2019, 9:48 PMDmitri Sh
12/13/2019, 1:58 AMJoey
12/13/2019, 3:56 AMArkadii Ivanov
12/13/2019, 4:50 PMjk2018
12/13/2019, 6:22 PMkpgalligan
12/13/2019, 7:40 PMAleksey Chugaev
12/13/2019, 9:48 PMnewSingleThreadContext
in iosMain
• I have built https://github.com/Kotlin/kotlinx.coroutines/tree/native-mt and installed it locally
• added kotlin.mpp.enableGranularSourceSetsMetadata=true
to gradle.properties
• commonMain depends on implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.2-native-mt-SNAPSHOT"
• iosMain depends on implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.2-native-mt-SNAPSHOT"
• using kotlin 1.3.61
Am I missing something?
P.S. I have also tried to build https://github.com/kpgalligan/MTCoroutines locally and it worked.pabl0rg
12/14/2019, 7:18 AMDmitri Sh
12/15/2019, 5:55 AMRamadan Al.
12/15/2019, 2:47 PMTask sharedlinkSharedDebugFrameworkIose: Compilation failed: Expected 'BaseContinuationImpl.invokeSuspend' but was 'org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl@1f36969b' * Source files: * Compiler version info: Konan: 1.3.61 / Kotlin: 1.3.60 * Output kind: FRAMEWORK e: java.lang.AssertionError: Expected 'BaseContinuationImpl.invokeSuspend' but was 'org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl@1f36969b' at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.getContinuation(IrToBitcode.kt:1936) at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.evaluateFunctionCall(IrToBitcode.kt:2055) at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.evaluateCall(IrToBitcode.kt:1795) at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.evaluateExpression(IrToBitcode.kt:784) ...