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): Allow the container and the listenable element to be … #55586

Closed
wants to merge 18 commits into from

Conversation

iteriani
Copy link
Contributor

…configurable for early event contract.

This will allow a multi-app application to listen to early events from different elements and place them on a separate field on the window.

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?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove pullapprove bot added the requires: TGP This PR requires a passing TGP before merging is allowed label Apr 30, 2024
@iteriani iteriani force-pushed the earlyeventcontract branch 3 times, most recently from bd8cfd2 to c847dd5 Compare April 30, 2024 00:20
@thePunderWoman thePunderWoman added the area: core Issues related to the framework runtime label Apr 30, 2024
@ngbot ngbot bot added this to the Backlog milestone Apr 30, 2024
@thePunderWoman thePunderWoman added action: review The PR is still awaiting reviews from at least one requested reviewer target: rc This PR is targeted for the next release-candidate labels Apr 30, 2024
Copy link
Contributor

@tbondwilkinson tbondwilkinson left a comment

Choose a reason for hiding this comment

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

Let's fix capture events too.

The smallest way is maybe

addEvents(types: string[], capture = false)

You'll need to also add an extra property for event types that are capture

@iteriani iteriani dismissed tbondwilkinson’s stale review April 30, 2024 19:21

comments all resolved

Copy link
Contributor

@tbondwilkinson tbondwilkinson left a comment

Choose a reason for hiding this comment

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

Last comment, otherwise things look good

@@ -9,7 +9,7 @@
import {createEventInfoFromParameters, EventInfo} from './event_info';

declare global {
interface Window {
interface Object {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's still weird to add this to the global Object.

I think you should do:

export declare interface EarlyJsactionDataContainer {
  _ejsa?: EarlyJsactionData;
}

constructor(private readonly earlyJsactionDataContainer: EarlyJsactionDataContainer = window,     private readonly container = window.document.documentElement) {
  this.earlyJsactionDataContainer._ejsa = ...;
}

replayEarlyEvents(earlyJsactionDataContainer: EarlyJsactionDataContainer = window) {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@iteriani iteriani force-pushed the earlyeventcontract branch 2 times, most recently from f89ade7 to ee62a89 Compare April 30, 2024 21:28
const eventType: string = earlyEventTypes[idx];
earlyJsactionData.c.removeEventListener(eventType, earlyEventHandler);
}
delete earlyJsactionContainer._ejsa;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a pre-existing code, but I wanted to mention that we generally try not to use delete operations to avoid potential performance penalties related to deopt in hidden classes in V8. We can set the value to undefined instead. Since this is pre-existing, we can do it in a separate PR.

}
earlyJsactionTracker[field][appId] = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do a tree-shakable dev-mode checks in this code? If yes, it might be great to assert whether earlyJsactionTracker[field][appId] already exists and throw an error (otherwise, we just override what we've stored before).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there's no such thing as a dev mode binary i think...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we do have some dev-mode flags 1P/3P compatible (via copybara transform) in the signals code.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can also do this in a followup PR (let's not block this PR on this change).

…configurable for early event contract.

This will allow a multi-app application to listen to early events from different elements and place them
on a separate field on the window.
… to be configurable for early event contract.
… to be configurable for early event contract.
… to be configurable for early event contract.
… to be configurable for early event contract.
… to be configurable for early event contract.
… to be configurable for early event contract.
… to be configurable for early event contract.
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

@iteriani looks great, just a couple minor refactoring proposals.

… to be configurable for early event contract.
… to be configurable for early event contract.
… to be configurable for early event contract.
… to be configurable for early event contract.
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

@iteriani thanks for addressing all the feedback 👍

@@ -5,7 +5,7 @@
```ts

// @public
export function bootstrapEventContract(field: string, container: Element, appId: string, events: string[], anyWindow?: any): EventContract;
export function bootstrapEventContract(field: string, container: Element, appId: string, events: string[], earlyJsactionTracker?: any): void;
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll probably need to re-generate golden files, this any would be replaced with Tracker type.

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.

reviewed-for: fw-core, primitives, public-api

… to be configurable for early event contract.
@iteriani iteriani 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 May 2, 2024
@iteriani
Copy link
Contributor Author

iteriani commented May 2, 2024

Caretaker note: TGP is clean, so this is safe to merge

… to be configurable for early event contract.
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

Reviewed-for: public-api

@AndrewKushnir AndrewKushnir removed the action: review The PR is still awaiting reviews from at least one requested reviewer label May 2, 2024
@iteriani
Copy link
Contributor Author

iteriani commented May 3, 2024

TGP is clean, so this is safe to merge

@iteriani iteriani added the action: merge The PR is ready for merge by the caretaker label May 3, 2024
@AndrewKushnir
Copy link
Contributor

AndrewKushnir commented May 3, 2024

TESTED=TGP (copy from #55586 (comment))

@AndrewKushnir
Copy link
Contributor

Caretaker note: the merge is scheduled for Monday, 05/06.

@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit 8f273ce.

AndrewKushnir pushed a commit that referenced this pull request May 6, 2024
…configurable for early event contract. (#55586)

This will allow a multi-app application to listen to early events from different elements and place them
on a separate field on the window.

PR Close #55586
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: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants