Support Kotlin higher-order functions/lambdas
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, kotlin
- 领域
- mobile
调研方向
未指定仓库文件或测试。首先追踪 NativeScript Android 的 Java 字节码封送,以及 kotlin.jvm.functions.Function1、Function2 和更高元数如何表示;将其与现有的 JavaScript 回调包装路径进行比较。完成标准是 Kotlin 函数参数可以直接接收 JavaScript 回调,而无需手动构造 FunctionX 实例。
由索引模型根据 Issue 内容生成。
描述
NativeScript supports marshalling Java bytecode generated by Kotlin. But Kotlin has a way to specify that a function takes another function in a much better way than Java.
Like this:
fun myfun(callback: (arg: String) -> Void)
It compiles to something like
public final void myfun(@org.jetbrains.annotations.NotNull final kotlin.jvm.functions.Function1<? super String, Void> callback)
where Function1 is a class containing an invoke method. Depending on how many args the function takes, it'll be called Function2, Function3 and so on.
Interacting with myfun from JavaScript would be done this way:
myfun(new kotlin.jvm.functions.Function1({ invoke: () => console.log("invoked") }))
It would be so cool if NativeScript supported Kotlin-functions out of the box, so the callback wouldn't need to be wrapped in FunctionX and myfun could be run via myfun(() => console.log("invoked")). This would make it easier to align with an Objective-C library, where blocks are supported.
To support Kotlin, my app.gradle currently looks like this:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.30"
}
}
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.30"
}
android {
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.test"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
- 主要语言
- C++
- 星标
- 563
- 派生
- 144
- 平均合并
- 10 小时 46 分钟
- 30 天内合并 PR
- 14
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NativeScript/android 的其他 Issue
-
难度 5/5 一周以上 新手友好度 38/100
NativeScript/android#2039 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 48/100
NativeScript/android#2024 ·
-
难度 5/5 一周以上 新手友好度 20/100
NativeScript/android#2020 ·
-
难度 5/5 一周以上 新手友好度 42/100
NativeScript/android#2019 ·
-
难度 4/5 3-5 天 新手友好度 55/100
NativeScript/android#1986 ·
查看 NativeScript/android 的全部 Issue
相似的 Issue
-
ai_reviewed
难度 2/5 1-3 小时 新手友好度 68/100
ydb-platform/ydb#53869 · 3 条评论 ·
-
bug cert blocker needs triage
难度 2/5 1-3 小时 新手友好度 82/100
project-chip/connectedhomeip#74373 ·
-
upstream update
难度 2/5 1-3 小时 新手友好度 75/100
conan-io/conan-center-index#31035 ·
-
Bug
难度 2/5 1-3 小时 新手友好度 68/100
-
documentation
难度 1/5 1 小时以内 新手友好度 85/100
vllm-project/vllm-ascend#17329 ·