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
jw
11/20/2024, 6:16 PM
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
jw
11/20/2024, 6:17 PM
For example, every single
Modifier
chain factory function
p
Pablichjenkov
11/20/2024, 6:28 PM
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.
Pablichjenkov
11/20/2024, 6:36 PM
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 🗝️
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