Skip to content
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

Declaring factory providers should be as easy as declaring class providers #6105

Closed
ewinslow opened this issue Dec 23, 2015 · 4 comments
Closed

Comments

@ewinslow
Copy link

@ewinslow ewinslow commented Dec 23, 2015

It would be awesome if instead of this:

  providers: [
    provide(Model, {
      deps: [Service],
      useFactory: (service :Service) :Model => service.getModel(...args),
    }),
  ],

I could just write this:

  providers: [
    (service :Service) :Model => service.getModel(...args),
  ],

Not sure how feasible it is (given the decorators spec doesn't allow for decorating plain functions IIRC), but figured I'd let my preference be known...

@PascalPrecht
Copy link
Contributor

@PascalPrecht PascalPrecht commented Dec 28, 2015

This is indeed nicer, unfortunately we can't emit metadata on functions. We lack typescript support here.

@PatrickJS
Copy link
Member

@PatrickJS PatrickJS commented Jan 4, 2016

Support for this can be added to Webpack as a plugin or a transform (think ng-annotate) until there is TypeScript support

@vicb
Copy link
Contributor

@vicb vicb commented Sep 25, 2016

Support for this can be added to Webpack as a plugin or a transform
👍

@vicb vicb closed this Sep 25, 2016
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Sep 9, 2019

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 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.