X Tutup
Skip to content

feat(router): user metadata in route configs#3541

Closed
danrasmuson wants to merge 1 commit intoangular:masterfrom
danrasmuson:master
Closed

feat(router): user metadata in route configs#3541
danrasmuson wants to merge 1 commit intoangular:masterfrom
danrasmuson:master

Conversation

@danrasmuson
Copy link
Copy Markdown
Contributor

Provide the ability to attach custom data onto a route and retrieve that data as an injectable (RouteData) inside the component.
Closes #2777

@danrasmuson
Copy link
Copy Markdown
Contributor Author

Two things I'm unsure about.

  1. Currently this is only implementing on 'Route' and not, 'AsyncRoute' or 'Redirect'. Please let me know if we want to implement on either / both of those and I will update the code and tests.
  2. Not sure on the status or workflow with Dart. This commit does not change any Dart code. Happy to update that as well.

@danrasmuson danrasmuson force-pushed the master branch 2 times, most recently from df31fce to 86d194a Compare August 8, 2015 01:49
@btford
Copy link
Copy Markdown
Contributor

btford commented Aug 10, 2015

Thanks @danielrasmuson!

Can you rebase this on master? I just landed a refactor to the router that should make this a bit easier.

I think this should be attached to the handler, and that'll make it agnostic for Route and AsyncRoute. I don't think we want it for Redirect.

If you get the tests passing for JS, I'll help make the Dart ones pass. No need to worry about that.

@btford btford added comp: router action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews effort2: days labels Aug 10, 2015
@danrasmuson
Copy link
Copy Markdown
Contributor Author

Sure thing Brian. I'll work on it.

Provide the ability to attach custom data onto a route and retrieve that data as an injectable (RouteData) inside the component.
Closes angular#2777
@danrasmuson
Copy link
Copy Markdown
Contributor Author

Hey @btford
I rebased the commit on master and attached the data to the handler. The tests are passing for JS, but are still failing for Dart. :(
Happy to change / add anything.

@btford
Copy link
Copy Markdown
Contributor

btford commented Aug 17, 2015

@danielrasmuson– thanks! taking a look now. If you don't mind, I'll just amend your commit with the few fixes for Dart

@btford btford added this to the alpha-36 milestone Aug 17, 2015
@btford btford closed this in ed81cb9 Aug 18, 2015
@btford
Copy link
Copy Markdown
Contributor

btford commented Aug 18, 2015

This landed in master.

I made some changes – I removed the arbitrary type restriction, and extraneous class in favor of an opaque token for injection.

See ed81cb9 for details.

Thanks, @danielrasmuson!

@cexbrayat
Copy link
Copy Markdown
Member

@btford If I read this correctly, the only way to access the data is to use @Inject(ROUTE_DATA). Is there a particular reason for not having a RouteData service? That would be more coherent with the rest (and easier to understand) don't you think?

@0x-r4bbit
Copy link
Copy Markdown
Contributor

@cexbrayat I think the reason for that is, that ROUTE_DATA is really just a simple value. Introducing yet another service introduces also additional complexity (that is not necessarily needed), no?

@cexbrayat
Copy link
Copy Markdown
Member

@PascalPrecht Right. But don't you think that having to use @Inject is a bit surprising compared to RouteParams which gives us a service? I think this is a very rare case (the only one?) where we can't rely on Type annotation in an app for something provided by the framework.
And we obtain an object as you pointed out, whereas RouteParams provides a get method.

These differences are a bit surprising, I thought it was worth pointing out.

@tommyminds
Copy link
Copy Markdown

I have to agree with @cexbrayat . @Inject(ROUTE_DATA) feels out of sync with the rest of the framework.

@0x-r4bbit
Copy link
Copy Markdown
Contributor

@TommyM I get @cexbrayat point that it doesn't feel common that ROUTE_DATA isn't a service compared to RouteParams. However, using @Inject() is a very common pattern, if you have to inject a bound value. Simply because it doesn't have a Type.

Maybe @btford can shed some light on the reasoning behind it.

@tommyminds
Copy link
Copy Markdown

@PascalPrecht Yes you are right. I did mean to say that ROUTE_DATA being a bound value instead of a service feels out of sync, not necessarily the use of @Inject()

@cexbrayat
Copy link
Copy Markdown
Member

@PascalPrecht @TommyM I think we all agree. @Inject is useful, but not very common to inject something provided by the framework, because it's usually a service and not a value. It's furthermore surprising when you use RouteParams and ROUTE_DATA side by side.

@0x-r4bbit
Copy link
Copy Markdown
Contributor

Yes, let's lean back and wait for @btford 's thoughts on this. I'm sure he'll shed some light into darkness once he can find some time.

@btford
Copy link
Copy Markdown
Contributor

btford commented Sep 27, 2015

Using a @Inject means you can specify a value of any type for data.

@cexbrayat @TommyM @PascalPrecht I'm open to discussing this more in another issue.

@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews cla: yes effort2: days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(router): user metadata in route configs

6 participants

X Tutup