Skip to content

feat(ivy): implement the getters of ViewContainerRef - #25092

Closed
marclaval wants to merge 1 commit into
angular:masterfrom
marclaval:vcref_injector
Closed

marclaval wants to merge 1 commit into
angular:masterfrom
marclaval:vcref_injector

Conversation

@marclaval

@marclaval marclaval commented Jul 25, 2018 •

Copy link
Copy Markdown
Contributor

This PR implements the getters of ViewContainerRef: element and injector.
As per @mhevery comment, parentInjector is deprecated.

@mary-poppins

Copy link
Copy Markdown

You can preview 14b38f8 at https://pr25092-14b38f8.ngbuilds.io/.

@mhevery mhevery left a 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.

I think this is the right approach.

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.

nit: Injector_ => NodeInjector

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

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.

I think this should not have been public. I think we should add @deprecate to this. My understanding is that because we have @SkipSelf it is at times necessary to get a hold of parent injector. Injector interfaces does not have a pointer to parent, hence we have this API. Also the Injectors for nodes are created lazily so I think this is the reason to be able to get parent.

I think this is an internal only think hence it should be deprecated.

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've only added the @deprecated flag on parentInjector, not sure if it is enough for now.

In the framework, we use it only in ViewContainerRef.createComponent() and on the NgComponentOutlet directive. I've tried to replace it with ``ViewContainerRef.injector` and all the tests are passing.

@marclaval marclaval added action: review The PR is still awaiting reviews from at least one requested reviewer target: major This PR is targeted for the next major release PR action: time-zone and removed action: discuss state: WIP labels Jul 26, 2018
@mary-poppins

Copy link
Copy Markdown

You can preview 5c6eff6 at https://pr25092-5c6eff6.ngbuilds.io/.

@marclaval marclaval changed the title [WIP] feat(ivy): implement the getters of ViewContainerRef feat(ivy): implement the getters of ViewContainerRef Jul 26, 2018
@mary-poppins

Copy link
Copy Markdown

You can preview b324fbe at https://pr25092-b324fbe.ngbuilds.io/.

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.

👍

BREAKING CHANGE: ViewContainerRef.parentInjector is deprecated without replacement
@mhevery

mhevery commented Jul 27, 2018

Copy link
Copy Markdown
Contributor

@mhevery mhevery added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 27, 2018
@mary-poppins

Copy link
Copy Markdown

You can preview 93627ea at https://pr25092-93627ea.ngbuilds.io/.

/** @deprecated No replacement */
get parentInjector(): Injector {
const parentLInjector = getParentLNode(this._hostNode).nodeInjector;
return parentLInjector ? new NodeInjector(parentLInjector) : new NullInjector();

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.

change new NullInjector() for Injector.NULL ?

@vicb

vicb commented Jul 27, 2018

Copy link
Copy Markdown
Contributor

rebased in #25174

@vicb vicb closed this Jul 27, 2018
@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.

5 participants