https://kotlinlang.org logo
#compose
Title
# compose
k

karandeep singh

05/03/2020, 7:26 PM
Copy code
@Composable
fun SomeComposableFunction() {
    val t = animatedFloat(0f)
    Canvas(modifier = Modifier.fillMaxWidth()) {

        // this gives error during compile/build
        onActive {

        }



        //Can't do this as well
        val someValue = remember {

        }



    }
}
is this expected behaviour? we can't access Composables inside lambda's which are in turn inside some composable?
a

Adam Powell

05/03/2020, 7:29 PM
yes, this is expected, it's like trying to call a
suspend
function from a non-suspending lambda block passed to a function call inside a suspending function.
k

karandeep singh

05/03/2020, 7:30 PM
Thank you for your quick respone @Adam Powell 🙂
👍 1
a

Adam Powell

05/03/2020, 7:30 PM
e.g.:
Copy code
fooScope.launch {
    view.setOnClickListener {
        something.await() // error
    }
}
there are varieties of inlining you can do that will permit both of these things, however. For example,
something.apply { }