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

feat(@nestjs/core): Add Transient Inquirer Injection #1637

Merged
merged 2 commits into from
Nov 15, 2019

Conversation

Aetherall
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

In a transient injectable, the current instance is bound to the context in which it is instanciated.
However, there is no way I am aware of to configure the behaviour of the injected injectable at the intanciation level

What is the new behavior?

This PR introduce a way to achieve this intention by adding a new provider in the InternalCoreModule.
The injection of the INQUIRER symbol token results in the inquirer to be injected into our transient injectable.

@Inject(INQUIRER) inquirer

An example with a concrete business use-case is available in the PR

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

The way we implemented the feature may not be ideal given the architecture of the injection mechanism, so @millehorde and myself are willing to take all measures you consider appropriated

@Aetherall Aetherall changed the title Transient inject inquirer feat(@nestjs/core): Add Transient Inquirer Injection Mar 14, 2019
@coveralls
Copy link

Pull Request Test Coverage Report for Build 1612

  • 13 of 15 (86.67%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 93.033%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/core/injector/injector.ts 6 8 75.0%
Totals Coverage Status
Change from base Build 1599: -0.1%
Covered Lines: 3295
Relevant Lines: 3448

💛 - Coveralls

@coveralls
Copy link

coveralls commented Mar 14, 2019

Pull Request Test Coverage Report for Build 1612

  • 11 of 13 (84.62%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+2.4%) to 95.563%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/core/injector/injector.ts 4 6 66.67%
Totals Coverage Status
Change from base Build 1599: 2.4%
Covered Lines: 3295
Relevant Lines: 3448

💛 - Coveralls

@kamilmysliwiec
Copy link
Member

Thanks for contribution! I'll review shortly

@nesimer
Copy link

nesimer commented Mar 21, 2019

Thanks ! 🔥
We rebased it on your latest work !

@kamilmysliwiec kamilmysliwiec changed the base branch from 6.0.0-next to master November 15, 2019 09:58
@kamilmysliwiec kamilmysliwiec changed the base branch from master to 6.10.0 November 15, 2019 12:11
@kamilmysliwiec kamilmysliwiec added this to the 6.10.0 milestone Nov 15, 2019
@kamilmysliwiec kamilmysliwiec merged commit b90a1a6 into nestjs:6.10.0 Nov 15, 2019
@kamilmysliwiec
Copy link
Member

I have finally found some time to look at this PR. Amazing job, thank you!

@msheakoski
Copy link

msheakoski commented Nov 15, 2019

@Aetherall I am trying to better understand as an end user how/when/why I would use this since there is no documentation yet. I read through the specs/code, but still cannot figure out what is going on. Are you able to give a simple example of a situation where this feature would be a good use case? Thank you!

@lock
Copy link

lock bot commented Feb 14, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants