Add url
field to routes to build path and use it everywhere
#1035
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Will fix #844
I considered multiple approaches to this. I think having an
url
field on the route object itself is the nicest, at least for using it.DirectVideoRoute.url({ videoid: ... })
reads very clearly to me. But it wasn't that straight forward to find a way that plays nicely with Typescript.Adding the
url
field toRoute
and keeping everyFooRoute
as typeRoute
is tricky because (a) in the beginning, not every route will have anurl
field, and (b) the url builder has different arguments per route, making it generic and more complicated. We certainly want to involveRoute
somehow such that thematch
function is well typed without the need to annotate the type of its argument. So yeah, this is what I came up with.url
even the right term? It always just returns a path. Which is an URL... or URI, I can never tell.Also: hide whitespace changes in githubs diff view when looking at this!
Obviously this is not nearly done, just a tiny proof of concept to get feedback. Which I'd like to get from @JulianKniephoff as well.