Skip to content

feat(ivy): support generation of flags for directive injection#23345

Closed
mhevery wants to merge 4 commits intoangular:masterfrom
mhevery:injection_fix
Closed

feat(ivy): support generation of flags for directive injection#23345
mhevery wants to merge 4 commits intoangular:masterfrom
mhevery:injection_fix

Conversation

@mhevery
Copy link
Copy Markdown
Contributor

@mhevery mhevery commented Apr 12, 2018

This change changes:

Compiler portion of #23342
Prep for #23330

feat(ivy): support injection even if no injector present

  • Remove default injection value from inject / directiveInject since
    it is not possible to set using annotations.
  • Module Injector is stored on LView instead of LInjector data
    structure because it can change only at LView level. (More efficient)
  • Add ngInjectableDef to IterableDiffers so that existing tests can
    pass as well as enable IterableDiffers to be injectable without
    Injector

@mhevery mhevery requested a review from kara April 12, 2018 19:30
Copy link
Copy Markdown
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, except for the fdescribe

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove fdescribe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread packages/core/src/render3/di.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to remove this? Looks like it's still used in this file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on two things in one PR, reverted

@mhevery mhevery force-pushed the injection_fix branch 3 times, most recently from 520e435 to 644e714 Compare April 12, 2018 19:41
Copy link
Copy Markdown
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mary-poppins
Copy link
Copy Markdown

@mhevery mhevery force-pushed the injection_fix branch 2 times, most recently from 7b8bcef to 8fd7d95 Compare April 12, 2018 20:05
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const flags = moveThatLogicFurtherDown(dependency); ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted

Copy link
Copy Markdown
Contributor

@vicb vicb Apr 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename template to factory or injectxxxyyy ? (comment, var name and expect)
(I'm also ok with removing this comment)
Use $r3$ instead of IDENT for consistency with other tests ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@mary-poppins
Copy link
Copy Markdown

@mary-poppins
Copy link
Copy Markdown

@mhevery mhevery added the target: major This PR is targeted for the next major release label Apr 12, 2018
@mary-poppins
Copy link
Copy Markdown

@mary-poppins
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constructor(public todoStore: TodoStore) {} should work now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@mary-poppins
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small typos, otherwise looks good to me

Comment thread packages/core/test/render3/di_spec.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to myService ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread packages/core/test/render3/di_spec.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crete -> create

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@mhevery mhevery force-pushed the injection_fix branch 2 times, most recently from 019b4c1 to e2a3a2f Compare April 13, 2018 00:57
Copy link
Copy Markdown
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mary-poppins
Copy link
Copy Markdown

@mary-poppins
Copy link
Copy Markdown

@mary-poppins
Copy link
Copy Markdown

Comment thread packages/core/src/di/defs.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no 'any' ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Comment thread packages/core/src/di/injector.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to be able to provide undefined by using a special value (ie {}) instead ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about it, and decided that it is not worth the complexity. We can always added later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useful comment ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated comment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would compilation result lives in source code? Shouldn't it using @Injectable() decorator?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few reasons:
1.) we currently don't compile core with ivy so the decorator does not get lowered.
2.) There is a circular dependency between the compiler and core which makes it hard for the compiler to compile tho core. Rather than solving that, we have opted for hand coding it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should probably be in the source code

@mhevery mhevery added action: merge The PR is ready for merge by the caretaker and removed action: merge The PR is ready for merge by the caretaker labels Apr 13, 2018
@mary-poppins
Copy link
Copy Markdown

@mary-poppins
Copy link
Copy Markdown

@IgorMinar IgorMinar added state: blocked and removed action: merge The PR is ready for merge by the caretaker labels Apr 13, 2018
@IgorMinar
Copy link
Copy Markdown
Contributor

this PR changes the API surface. @mhevery let's discuss tomorrow before merging this.

@mhevery mhevery added action: merge The PR is ready for merge by the caretaker and removed state: blocked labels Apr 13, 2018
@mhevery
Copy link
Copy Markdown
Contributor Author

mhevery commented Apr 13, 2018

Discussed with @IgorMinar and we agreed to merge.

@IgorMinar
Copy link
Copy Markdown
Contributor

we agreed because the api is wrong and needs to be corrected before the release.

mhevery added 4 commits April 13, 2018 13:36
This change changes:
- compiler uses `directiveInject` instead of `inject` for `Directive`s
- unifies the flags in `di` as well as `render3`
- changes the signature of `directiveInject` to match `inject` In prep for angular#23330
- compiler now generates flags for injection.

Compiler portion of angular#23342
Prep for angular#23330
- Remove default injection value from `inject` / `directiveInject` since
  it is not possible to set using annotations.
- Module `Injector` is stored on `LView` instead of `LInjector` data
  structure because it can change only at `LView` level. (More efficient)
- Add `ngInjectableDef` to `IterableDiffers` so that existing tests can
  pass as well as enable `IterableDiffers` to be injectable without
  `Injector`
@mary-poppins
Copy link
Copy Markdown

@IgorMinar IgorMinar closed this in 6f213a7 Apr 13, 2018
IgorMinar pushed a commit that referenced this pull request Apr 13, 2018
- Remove default injection value from `inject` / `directiveInject` since
  it is not possible to set using annotations.
- Module `Injector` is stored on `LView` instead of `LInjector` data
  structure because it can change only at `LView` level. (More efficient)
- Add `ngInjectableDef` to `IterableDiffers` so that existing tests can
  pass as well as enable `IterableDiffers` to be injectable without
  `Injector`

PR Close #23345
IgorMinar pushed a commit that referenced this pull request Apr 13, 2018

export declare const enum InjectFlags {
Default = 0,
SkipSelf = 1,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the order? It's a bitmask anyway o:

@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 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants