question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@lazy not working with @autoinject

See original GitHub issue

I’m submitting a bug report

  • Library Version: 1.3.2

Please tell us about your environment:

  • Operating System: Windows 10

  • Node Version: 6.11.2

  • NPM Version: 4.6.1
  • JSPM OR Webpack AND Version JSPM 0.16.48 (reproduced with Aurelia CLI v0.31.1)
  • Browser: all

  • Language: TypeScript 2.4.2

Current behavior: Constructor arguments decorated with @lazy are injected with undefined when class is @autoinjected. Code, live demo.

Expected/desired behavior:

  • What is the expected behavior? @autoinject and @lazy should work well together. It probably was after #111 was merged.

  • What is the motivation / use case for changing the behavior? I want to be able to do this:

@autoinject
export class Alert {
  constructor(private i18n: I18N, @lazy(TemplatingEngine) private templatingEngine: () => TemplatingEngine) {
  }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
doktordirkcommented, Apr 30, 2018

@ccrd yes, for all the resolver decorators, the type of the metadata and the inject property won’t match and hence the current implementation of autoinject+resolver_decorators won’t work.

@EisenbergEffect as such sure, but that was a hack. anyways, i did dig further and found that this bug was introduced when fixing that issue #121 in pr #129. however, that issue highlights, that the design of @lazy et al., didn’t took inheritance into account. i’ll see if i can find some solution

2reactions
EisenbergEffectcommented, Jun 14, 2018

Merged the fix 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Autofixture Constructer injection lazy loading - Stack Overflow
I am using autofixture in my unit tests and it is great the way that it works as an automocker. However I have...
Read more >
Dependency Injection: Basics | Aurelia
Learn about how to leverage Aurelia's dependency injection container, the power behind all object creation in Aurelia applications.
Read more >
Browser-level image lazy loading for the web - web.dev
This post covers the loading attribute and how it can be used to control the loading of images.
Read more >
Contexts and Dependency Injection - Quarkus
It may happen that some beans from third-party libraries do not work correctly in ... normal scoped beans must be used as described...
Read more >
Service Container - The PHP Framework For Web Artisans
If a class has no dependencies or only depends on other concrete classes (not interfaces), the container does not need to be instructed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found