Support Kotlin higher-order functions/lambdas
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, kotlin
- Lĩnh vực
- mobile
Hướng nghiên cứu
Không có tệp hoặc bài kiểm thử nào trong repository được nêu tên. Hãy bắt đầu bằng cách lần theo quá trình marshalling bytecode Java của NativeScript Android và cách kotlin.jvm.functions.Function1, Function2 cùng các arity cao hơn được biểu diễn; so sánh điều đó với đường dẫn wrapping callback JavaScript hiện có. Công việc được coi là hoàn tất khi các tham số hàm Kotlin có thể nhận trực tiếp callback JavaScript mà không cần tạo thủ công các instance FunctionX.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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"
}
}
- Ngôn ngữ chính
- C++
- Star
- 563
- Fork
- 144
- Merge trung bình
- 10 giờ 46 phút
- Pull request đã merge (30 ngày)
- 14
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NativeScript/android
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
NativeScript/android#2039 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
NativeScript/android#2024 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
NativeScript/android#2020 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
NativeScript/android#2019 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
NativeScript/android#1986 ·
Tất cả issue của NativeScript/android
Issue tương tự
-
Website Doc Typo Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
autowarefoundation/autoware_universe#13413 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
automated-analysis bug memory-safety
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100