hey all, when i try to begin writing ```class Rout...
# ballast
a
hey all, when i try to begin writing
Copy code
class RouterViewModel(
    viewModelCoroutineScope: CoroutineScope
) : BasicRouter<AppRoutes>(config = BallastViewModelConfiguration.Builder())
there's an error on BasicRouter because the <init> is private on BasicViewModel. additionally it claims to not find the config field. Clearly this is strange as BasicViewModel has a public secondary constructor defined right there where i can see it. am on ballast 2.3.3
huh, something about secondary constructors OR typealiases means the compiler doesnt understand what's going on until all parameters have been supplied. the more you know
whoa! while i have you here: i guess there's no way to create a routing table from sealed classes? i just like those a bunch and they could be handy for supplying nav args
c
With the original snippet, you need to pass the config, not the builder, to the constructor. It also requires you to pass an eventHandler (even if you’re not actively using it, since the
eventHandler
parameter does not have a default value). It does not require all parameters to be specified, just the ones without default values
a
sorry i knew that i probably didnt need to share that code, it was unfinished and not exemplary of code i thought should work
the actual problem was typing in
config =
did not seem to make the compiler understand the constructor it was working with
but yes, just pushing through and supplying necessary parameters made it stop complaining, very small usability thing that is surely not ballast's fault
c
yeah, I think there are some rough edges with typealiases, unfortunately, and not much that can be done about it right now
And the
Route
and
RoutingTable
are both pretty interfaces, and you could probably make it work to define your routes with sealed classes if you’d like. I haven’t tried it though, so I don’t know the full extent of what would be required. The reason it is not offered out-of-the-box is that there is no way to automatically enumerate all sub-classes of a sealed class, so you’d need to manually build the list of routes to pass to the routing table. The only way to automatically build a list of routes without reflection or code generation is with an enum.
a
makes sense, maybe i'll give it a spin once i have some real routing going. i stopped considering the solution because if the sealed class destinations weren't being created by me but being generated from string routes, it might be hard to supply constructor parameters anyway. but a lot of ballast seems hackable so maybe its more feasible than i think. very surface level thoughts as im only just dipping in