-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for Typed Params #1443
Fixes for Typed Params #1443
Conversation
@@ -62,6 +62,20 @@ function objectKeys(object) { | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protoKeys
was necessary because I used prototypal inheritance for ParamsSet, like we discussed. objectKeys
doesn't work for prototypal inheritance.
rebased, squashed, etc. Summary of changes is as follows:
closes #1396
Closes #1433
closes #1435
|
@nateabele I'm going to argue for a couple of additional Type system changes: optional paramsI don't think optional params should remove their segments from the url.See the following state definition
Due to squashing of slashes in $urlMatcherFactory like so:
I couldn't come up with any reasonable rules for matching missing params, that would make sense in all scenarios. UrlMatcher.format() applying defaultsI'm considering if
I think some users will expect Injecting Type definitionI do not think we should support injectable Type definition objectsHere is my argument: After deferring state definition until Runtime in my PR, I loaded up the UI-Router sample app. It's doing: I have considered a few approaches to addressing this:
Everything feels either just plain wrong or like a one-use-case workaround. I think I would prefer to define and register Types at config time. I don't think injectable type definitions are going to be common, and if somebody needs their encode or decode injected for whatever reason, we can point them to the $rti gist. |
- make state.ownParams and params use Param type
feat($urlMatcherFactory): add function to get a RegExp Type
- param Type(s) are not available until runtime because they can be injected. UrlMatcher requires Type. StateBuilder creates UrlMatchers. Therefore, states must be built JIT at runtime.
feat($urlMatcherFactory): unify params handling code for path/search feat($urlMatcherFactory): add a defaultType that does string coersion and supports arrays (for params) feat($urlMatcherFactory): separate default Type(s) for path/query params Closes #1414
- move $types from UrlMatcher.prototype to $UrlMatcherFactoryProvider closure
I made However, I ran across another use case that becomes problematic. I know we discussed it in depth today, but I'm still not feeling good about deferring config-type-stuff to runtime. All I really need at config time is So, I think I have a workable proposal: Change from:
I like this because it doesn't jump through hoops, is easy to develop against, and smells better to me overall. |
👍 |
No description provided.