Rafael Costa
03/06/2024, 5:55 PMdave08
03/07/2024, 12:13 PMdave08
03/07/2024, 12:14 PMRafael Costa
03/07/2024, 12:16 PMI'm a bit sceptic of if a type parameter on EVERY destination annotation is more readable than the "old" separate annotation...Any specific reason for it not to be as readable? It's just moving some characters around π It allows us to have multiple Destination annotations in a given Composable function, each having its own NavGraph. Otherwise with multiple Destination multiple NavGraphs it would be impossible to know which is which. There's also other side benefits on the ergonomics of defining a start for a graph, etc.
dave08
03/07/2024, 12:17 PMdave08
03/07/2024, 12:17 PMdave08
03/07/2024, 12:18 PMRafael Costa
03/07/2024, 12:18 PMI haven't yet seen any libraries using type parameter on annotations in the first place?Why should that be a reason to not do it? π€
But maybe at least not requiring them for destinations in the root graph?You can always do something like
typealias RootDestination = Destination<RootGraph>
(Although I should test that it works π with KSP)Rafael Costa
03/07/2024, 12:20 PMdave08
03/07/2024, 12:21 PMtypealias
in that case... if you have a reason (not just aesthetics...) for it that's fine, just think that a lot of people will only need one graph, and that should be easy and short.dave08
03/07/2024, 12:22 PMRafael Costa
03/07/2024, 12:22 PMNavGraphs.root
to pass to DestinationsNavHostRafael Costa
03/07/2024, 12:22 PMRafael Costa
03/07/2024, 12:23 PMMaybe have that typealias built in as a short cut?That's a possibility, yes π Let's see if I get more feedback like yours!
Rafael Costa
03/07/2024, 12:23 PMRafael Costa
03/07/2024, 1:46 PM@RootDestination
really be so much better than @Destination<RootGraph>
though? π
Especially considering, it is easier to understand how to use custom nav graphs there instead of Root π€
I feel like this is going to be just fine π€ π
dave08
03/07/2024, 1:50 PM@Component<Singleton>
to make it clear that only Singleton
scope can be used there... maybe you'll be the first to give them the idea π. We're all just too used to scoping with a separate annotation, I actually never even thought it was possible π.Rafael Costa
03/07/2024, 1:55 PMRafael Costa
03/07/2024, 1:56 PMRafael Costa
03/07/2024, 1:58 PMRafael Costa
03/07/2024, 1:58 PMRafael Costa
03/08/2024, 2:52 PMUnfortunately, Dagger 2 is a java annotation processor and, unlike Kotlin, Java annotations cannot have type parameters:So yes, I was right, type arguments aren't a thing on java, so that explains why we haven't seen this before.