Skip to content

refactor(core): avoid injecting DestroyRef in EventEmitter#58219

Closed
cexbrayat wants to merge 1 commit intoangular:mainfrom
cexbrayat:fix/destroy-ref-event-emitter
Closed

refactor(core): avoid injecting DestroyRef in EventEmitter#58219
cexbrayat wants to merge 1 commit intoangular:mainfrom
cexbrayat:fix/destroy-ref-event-emitter

Conversation

@cexbrayat
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the new behavior?

destroyRef is never used in EventEmitter so we can spare the injection and leave it undefined. The field still needs to be there as it is declared in the OutputRef interface.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

`destroyRef` is never used in `EventEmitter` so we can spare the injection and leave it undefined.
The field still needs to be there as it is declared in the `OutputRef` interface.
@pullapprove pullapprove bot requested a review from alxhub October 16, 2024 11:18
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Oct 16, 2024
@ngbot ngbot bot added this to the Backlog milestone Oct 16, 2024
@JeanMeche JeanMeche requested a review from devversion October 16, 2024 12:39
@JeanMeche
Copy link
Member

JeanMeche commented Oct 16, 2024

Requesting a review from Paul who introduced it in #54650. (866271a)

@devversion
Copy link
Member

Removing destroyRef here is unintended because the destroyRef is intentionally exposed for automatic clean-up when event emitters, or output refs are used in outputToObservable.

It's optional for cases where EventEmitter is created outside of injection contexts.

@alxhub
Copy link
Member

alxhub commented Oct 16, 2024

As @devversion says, this is required for outputToObservable to work correctly. EventEmitter should only be used for @Outputs, where injection context is available, so injecting DestroyRef is not an issue.

@alxhub alxhub closed this Oct 16, 2024
@cexbrayat
Copy link
Member Author

cexbrayat commented Oct 16, 2024

@devversion @alxhub Ok thanks 👍 But is it normal that no test fail when the injection is removed then?

@devversion
Copy link
Member

devversion commented Oct 16, 2024

@cexbrayat we should have one. I do see a few for clean-up tests for outputToObserverable, but could be possible that we are missing one for EventEmitter. I briefly remember one, but not sure where. Definitely feel free to add a test. that would be great

@angular-automatic-lock-bot
Copy link

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

Labels

area: core Issues related to the framework runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants