Thread
#compose
    Stefano Rodriguez

    Stefano Rodriguez

    1 year ago
    Is there a way to “store” a composable function as a method of a data class/interface and call it programmatically from another composable function? I’m getting a weird java.lang.NoSuchMethodError when trying to invoke the
    render
    method
    interface TestScreen<State: Any> {
        val name: String
        val initialState: State
        @Composable
        fun render(state: State, setState: (State) -> Unit)
    }
    a

    alorma

    1 year ago
    yes
    Stefano Rodriguez

    Stefano Rodriguez

    1 year ago
    looks really similar to what I’m trying to achieve, how do you call the
    build
    function? You just use it normally? Perhaps the problem is related to the generic
    State
    type and I have somehow to erase it
    Adam Powell

    Adam Powell

    1 year ago
    Can you post the full error you're seeing?
    Stefano Rodriguez

    Stefano Rodriguez

    1 year ago
    a

    alorma

    1 year ago
    i call it from inside a composable function
    Stefano Rodriguez

    Stefano Rodriguez

    1 year ago
    yeah, me too
    Stefano Rodriguez

    Stefano Rodriguez

    1 year ago
    I’m just doing this:
    @Composable
    fun PreviewBox(
        selectedTestScreen: TestScreen<out Any>,
    ) {
            selectedTestScreen.doRender()
    }
    a

    alorma

    1 year ago
    yes, it looks like it don0t know the type, try with *
    Stefano Rodriguez

    Stefano Rodriguez

    1 year ago
    it’s the same
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    Does your method implementation also have the Composable annotation?
    Stefano Rodriguez

    Stefano Rodriguez

    1 year ago
    Yes
    @Adam Powell So i discovered the issue. It’s not related to the generics but to the fact that the interface is declared in another module w.r.t. where I use it
    Adam Powell

    Adam Powell

    1 year ago
    Was the compose compiler plugin not enabled for one of the modules?