t

    thevery

    3 years ago
    I know there is no reflection support to js and native, but is there any way to implement dynamic proxy? I want to create something like https://github.com/square/retrofit for common code (Android+iOS)
    d

    diesieben07

    3 years ago
    On the Java side you can use the normal JDK proxy system. On the JS side you can look at how Kotlin objects are constructed and then just use native Javascript code (
    js
    function) to create those dynamically.
    Not sure about native, I have not worked with that part at all yet.
    t

    thevery

    3 years ago
    Native is the most challenging part actually. @olonho maybe you can help here?
    olonho

    olonho

    3 years ago
    not sure if this is something that could be properly implemented with native. What exactly do you want it to do? Can you write same/similar code in C?
    f

    fabianterhorst

    3 years ago
    feels free to post your github repo if you would like to open source it. Im interested in an retrofit api interface compatible rest client for kotlin native and kotlin/js. Need the same and would also implement it.
    how does the serialization lib does it for kotlin native
    looks like its directly implemented in the compiler there
    t

    thevery

    3 years ago
    Plain C is not possible I think. Simple explanation of retrofit internals could be found here: https://medium.com/@jintin/retrofit-2-b0c80d5caadf
    @fabianterhorst yes, compiler plugin (but API is not available yet as I understand)
    f

    fabianterhorst

    3 years ago
    and annotation processor support for kotlin native is also not planned?
    t

    thevery

    3 years ago
    j

    jw

    3 years ago
    The way that I'm doing it now is with an expect interface in common, an actual interface in JVM with the Retrofit annotations, and then an actual interface and implementation in JS with manual calls to
    fetch
    olonho

    olonho

    3 years ago
    right, most things achieved with reflection on dynamic runtimes ae better be done with the compiler plugins on Native
    t

    thevery

    3 years ago
    @olonho any eta/plans for native plugin api?
    olonho

    olonho

    3 years ago
    Well, some unstable form is already here, kotlinx.serialization plugin is written this way