You should avoid doing so because you'll end up with multiple sources of truth which can result in a hard to debug obscure bugs + it makes your api a bit more clunky.
👍🏻 1
🙏 1
MR3Y
06/06/2024, 7:51 PM
Consider accepting a lambda parameter instead.
👍🏻 1
s
Stylianos Gakis
06/06/2024, 8:37 PM
Make it take:
Copy code
param: T
setParam: (T) -> Unit
Or even
Copy code
getParam: () -> T
setParam: (T) -> Unit
There's never a good reason to make it take MutableState instead.
👍🏻 1
🙏 1
👍 1
z
Zach Klippenstein (he/him) [MOD]
06/06/2024, 8:41 PM
Lambdas are nice because at some point you’ll need to actually do some on a value coming in or out and if you have a lambda you can just do it. Also makes it easier to write tests