Problem Description
I'm creating an abstraction for my compose functions that use my custom view:
@Composable
fun DisposeBanner(bannerView: BannerView) {
DisposableEffect(key1 = true) {
onDispose {
bannerView.destroyAd()
}
}
}
However, as this function doesn't actually render any components I didn't want it to stick with the @Composable markup, but rather to indicate that it can only be used in compose functions through an extension.
My failed attempt
When trying to do:
fun Composable.disposeBanner(bannerView: BannerView) {
DisposableEffect(key1 = true) {
onDispose {
bannerView.destroyAd()
}
}
}
I get an error saying: "@Composable invocations can only happen from the context of a @Composable function"
Is it possible to do what I want?