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

refactor(core): Split Dispatcher into base class. #55372

Closed

Conversation

tbondwilkinson
Copy link
Contributor

@tbondwilkinson tbondwilkinson commented Apr 16, 2024

This will enable refactoring existing usages of the Dispatcher that use APIs that we do not intend to support, like registerGlobalHandler and registerEventInfoHandlers to use the LegacyDispatcher.

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.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Currently dispatcher with its non-desirable behavior is in one file.

Issue Number: N/A

What is the new behavior?

Dispatcher is split into base_dispatcher, dispatcher, and legacy_dispatcher. Goal is to finish with dispatcher and legacy_dispatcher.

Does this PR introduce a breaking change?

  • Yes
  • No

@tbondwilkinson tbondwilkinson force-pushed the jsaction-dispatcher branch 5 times, most recently from 416192f to f0b329b Compare April 19, 2024 21:03
@tbondwilkinson
Copy link
Contributor Author

tbondwilkinson commented Apr 19, 2024

TESTED=TGP

@tbondwilkinson tbondwilkinson requested review from iteriani, thePunderWoman and rahatarmanahmed and removed request for iteriani April 19, 2024 21:04
@tbondwilkinson tbondwilkinson marked this pull request as ready for review April 19, 2024 21:05
@pullapprove pullapprove bot added the requires: TGP This PR requires a passing TGP before merging is allowed label Apr 19, 2024
Copy link
Contributor

@thePunderWoman thePunderWoman left a comment

Choose a reason for hiding this comment

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

LGTM

@tbondwilkinson

This comment was marked as outdated.

* element of the DOM event, and invokes the handler associated with the
* jsaction.
*
* @param getHandler A function that knows how to get the handler for a
Copy link
Contributor

Choose a reason for hiding this comment

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

Update jsdoc.

Isn't dispatchDelegate supposed to return a handler? Or does the base dispatcher hand the responsibility of calling the handler to dispatchDelegate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Base dispatcher hands the responsibility of calling the handler to dispatchDelegate yeah. Updated the comment.

{eventReplayer = undefined}: {stopPropagation?: boolean; eventReplayer?: Replayer} = {},
) {
this.eventReplayer = eventReplayer;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you keep the empty lines between methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's odd not sure why all the whitespace got removed.

* Registers deferred functionality for an EventContract and a Jsaction
* Dispatcher.
*/
export function registerDispatcher(eventContract: UnrenamedEventContract, dispatcher: Dispatcher) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need both this and the registerDispatcher in base_dispatcher.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because one does not extend the other, the two registerDispatcher functions are technically distinct due to type differences.

I also think it's nice to have the register function available for whichever file you include.

This will enable refactoring existing usages of the Dispatcher that use
APIs that we do not intend to support, like registerGlobalHandler and
registerEventInfoHandlers to use the LegacyDispatcher.
@tbondwilkinson tbondwilkinson added action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime labels Apr 22, 2024
@ngbot ngbot bot modified the milestone: Backlog Apr 22, 2024
@thePunderWoman thePunderWoman added the target: minor This PR is targeted for the next minor release label Apr 23, 2024
@tbondwilkinson tbondwilkinson added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Apr 23, 2024
@tbondwilkinson
Copy link
Contributor Author

tbondwilkinson commented Apr 23, 2024

Caretaker note: This needs cl/626467219 patched on top of the sync CL. Internal test failures are pre-existing and unrelated.

@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit 98e8613.

@tbondwilkinson tbondwilkinson deleted the jsaction-dispatcher branch April 24, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note requires: TGP This PR requires a passing TGP before merging is allowed target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants