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
Conversation
bd8cfd2
to
c847dd5
Compare
There was a problem hiding this 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
i can't respond but i did update
packages/core/primitives/event-dispatch/src/earlyeventcontract.ts
Outdated
Show resolved
Hide resolved
packages/core/primitives/event-dispatch/src/earlyeventcontract.ts
Outdated
Show resolved
Hide resolved
packages/core/primitives/event-dispatch/src/earlyeventcontract.ts
Outdated
Show resolved
Hide resolved
packages/core/primitives/event-dispatch/test/eventcontract_test.ts
Outdated
Show resolved
Hide resolved
packages/core/primitives/event-dispatch/test/eventcontract_test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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) {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
f89ade7
to
ee62a89
Compare
packages/core/primitives/event-dispatch/src/earlyeventcontract.ts
Outdated
Show resolved
Hide resolved
const eventType: string = earlyEventTypes[idx]; | ||
earlyJsactionData.c.removeEventListener(eventType, earlyEventHandler); | ||
} | ||
delete earlyJsactionContainer._ejsa; |
There was a problem hiding this comment.
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] = {}; |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
ee62a89
to
a77d9d5
Compare
… to be configurable for early event contract.
… to be configurable for early event contract.
There was a problem hiding this 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.
There was a problem hiding this 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Caretaker note: TGP is clean, so this is safe to merge |
… to be configurable for early event contract.
There was a problem hiding this 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
TGP is clean, so this is safe to merge |
TESTED=TGP (copy from #55586 (comment)) |
Caretaker note: the merge is scheduled for Monday, 05/06. |
This PR was merged into the repository by commit 8f273ce. |
…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?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information