Hello, In the Jetnews app, I saw we are using an ...
# compose
t
Hello, In the Jetnews app, I saw we are using an AppContainer which contains the variables we will share across the app (such as repositories). We have to pass down this object to each component. What prevent us from using ambient?
☝️ 2
m
I am using Ambient. only that I need to write
val controller = controller
all the time, because the
controller
is accessed inside
onClicks
(you cannot call composible inside these)
a
I'm sure Ambient would work, however the problem with Ambient is that eventually it would lead to a lot of implicit dependencies and then you might have to deal with a lot of bad things in runtime instead of compile time. So I'm guessing that's why they were avoided
t
I understand the concerns @Adrian Blanco , but I think having all the parents asking for parameters they will only use for a single component is also source of troubles. When we will remove our child component, we will have a dependency we don’t need anymore. What can be done is to use Ambiant at parent level of a component that doesn’t need to hold specific code. Usually I ask myself “Can I use this in another project”? If so, no ambiant inside (unless it’s for theming or so)
c
https://twitter.com/mjackson/status/1195431511417208834 this could be a interesting thing to read, I think that context (react) and ambients are similar concepts
👍 1
a
I think this will probably be one of the things that will get a lot more of attention and care in the future. There's also a ton of potential with inverting the dependencies where instead of having the compose view handle everything, you could have business logic nodes (eg react component equivalent) which use eg dagger and supply simple compose views.
👍 1
t
Thanks for sharing