Is there any flag in the compose compiler or detek...
# compose
p
Is there any flag in the compose compiler or detekt rule to signal, highlight or warn when a Composable function calls a non Composable function?
j
Can you describe what you're trying to do with that, because I think you'll find there's probably 10x more non-Composable function calls than Composable function calls in a single Composable function.
2
For example, every single
Modifier
chain factory function
p
Humm, I did not think about modifiers. Basically noticed a few bugs due to functions being called more than 2 times consecutively. Think of accidentally calling from a Composable, a function in the ViewModel that logs some analytics remotely. So I was thinking, maybe having some warning ⚠️ that could help with identifying the calling sites where it could happen.
I believe a fix could be to wrap that call within a Composable function that uses remember so it could return the cached result value the next time is called during a recomposition with the same key 🗝️
c
That’s what side effects are meant for. https://developer.android.com/develop/ui/compose/side-effects
p
Thanks Christian I do agree that's the purpose of Side Effects but you know of any tool to enforce it? - for the case someone accidentally does a direct call and doesn't use Side Effects
🚫 1