packages icon indicating copy to clipboard operation
packages copied to clipboard

[draft] [go_router] wrap path_utils content in RoutePattern

Open cedvdb opened this issue 1 year ago • 4 comments

part of https://github.com/flutter/flutter/issues/155567

This is a draft PR to see if some part of go_router can be refactored to be more readable. Currently it is hard to know if a parameter / variable is a pattern such as /books/:bookId or a path such as /book/123 when reading the code of a given function. This PR is a stab on improving the readability on that front.

It wraps the content of path_utils in a RoutePattern class.

@chunhtai this does not compile but I'm interested in knowing whether this is a direction the team wants to go or not, I'll just close this if not.

I'll probably wait for my other PR's to go through before going any further anyway.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

cedvdb avatar Sep 25 '24 23:09 cedvdb

wrapping path_utils does make it more readable. but not sure about changing the naming convention is worthing the breaking change.

I believe it's possible to make it only internal without breaking changes, that's the requirement I'm doing this under

cedvdb avatar Sep 30 '24 22:09 cedvdb

if we want to rename

path -> pattern location -> path

I would like us to change the public facing API such as GoRoute.path -> GoRoute.pattern etc.

but i am not sure if this worth it.

As for wrapping path_util, I think we can do it as less as breaking change as possible, and I am onboard with this.

chunhtai avatar Sep 30 '24 22:09 chunhtai

@chunhtai So the convention used is that path is a /books/:bookId and location is /books/123 ? I had a feeling that was the case but wasn't sure. I don't think renaming is necessary.

cedvdb avatar Sep 30 '24 22:09 cedvdb

@chunhtai So the convention used is that path is a /books/:bookId and location is /books/123 ? I had a feeling that was the case but wasn't sure. I don't think renaming is necessary.

yes. that is the current naming convention.

chunhtai avatar Sep 30 '24 22:09 chunhtai

(triage) Hi @cedvdb are you still planning on coming back to this pr?

chunhtai avatar Nov 21 '24 22:11 chunhtai

@chunhtai This is not my priority, so I don't think I will in the near future at least. So you can close, I'll reopen if I happen to come back to this

cedvdb avatar Nov 21 '24 22:11 cedvdb

Thanks for reply, I will close this pr for now, feel free to reopen if you have time in the future

chunhtai avatar Nov 21 '24 23:11 chunhtai