Tristan Caron
10/24/2019, 1:50 PMjim
10/24/2019, 1:52 PMAmbient
, but please be super careful and use it very sparingly. It is quite dangerous in the sense that it isn't statically checked and can very quickly make your apps a maintainability nightmare.Fudge
10/24/2019, 1:53 PMjim
10/24/2019, 1:55 PMFudge
10/24/2019, 1:55 PMjim
10/24/2019, 1:57 PMTristan Caron
10/24/2019, 2:02 PMPage(user = user, avatarSize = avatarSize)
// ... which renders ...
PageLayout(user = user, avatarSize = avatarSize)
// ... which renders ...
NavigationBar(user = user, avatarSize = avatarSize)
// ... which renders ...
Link(href = user.permalink) {
Avatar(user = user, size = avatarSize)
}
Fudge
10/24/2019, 2:02 PMjim
10/24/2019, 2:13 PMPageLayout
probably shouldn't have access to user and avatarSize; it should just do layout and the children should capture the values lexically. Probably same is true of NavigationBar
, depending on your implementation.
Often, users claim they need to plumb parameters through every intermediate widget, but when they go to implement it, realize that lexical scoping often allows you to jump across levels.wasyl
10/24/2019, 2:39 PMfun PageLayout(navigationBar: @Compose() () -> Unit, content: @Composable() () -> Unit
? And then navigationBar child can be fun NavigationBar(leading: @Composable() () -> Unit, items...
etc.? And then most of the time you’ll pass things just one-two levels down at most?George Mount
10/24/2019, 3:02 PMjim
10/24/2019, 3:32 PM