Just wonder: using `compositionLocal` seems like n...
# compose
t
Just wonder: using
compositionLocal
seems like not a good idea, what about using built-in
compositionLocal
like
LocalContentColor
?
j
Use your best judgement, Sometimes using CompositionLocals is necessary, but it is a good idea to avoid composition locals whenever possible. Also avoiding anything that is platform-specific (eg. AAC ViewModel, ConstraintLayout, and Navigation are Android-only so I'd typically avoid them) and anything that is application specific (eg. direct calls into your application backend) should also be avoided. All CompositionLocals break widget API modularization because any widget which uses your widget is now implicitly exposing additional public API that they may not have intended to expose and may have considered to be an implementation detail. They are also more difficult to reason about the data flow when things happen implicitly, which is especially troublesome for refactoring. So avoid when possible, but ultimately you gotta do what you gotta do to build your app.
t
Thanks! I'm considering removing the use of custom CompositionLocals and platform-specific components (I'm using ViewModel, Navigation and other Jetpack components which blocking the app from cross-platform), I might need to reconsider the app architecture.
🎉 1