refactor(core): Refactor parts of event_replay into a shared library and move stashing function to listening code#56172
Conversation
89bf6c9 to
db58abd
Compare
7e02127 to
7ffcd83
Compare
dcde347 to
03c8f94
Compare
0e8abdd to
b9555dc
Compare
There was a problem hiding this comment.
I think we can avoid referencing IS_EVENT_REPLAY_ENABLED here and instead check if the eventDelegation.eventContract is defined:
| export const initGlobalEventDelegation = ( | |
| eventDelegation: GlobalEventDelegation, | |
| injector: Injector, | |
| ) => { | |
| if (injector.get(IS_EVENT_REPLAY_ENABLED, EVENT_REPLAY_ENABLED_DEFAULT)) { | |
| return; | |
| } | |
| const dispatcher = new EventDispatcher(invokeRegisteredListeners); | |
| registerDispatcher(eventDelegation.eventContract, dispatcher); | |
| }; | |
| export const initGlobalEventDelegation = ( | |
| eventDelegation: GlobalEventDelegation, | |
| eventContractContainer: Element, | |
| ) => { | |
| if (eventDelegation.eventContract) { | |
| // EventContract is already configured for this application, | |
| // no need to create a new one, exit. | |
| return; | |
| } | |
| const container = new EventContractContainer(eventContractContainer); | |
| const eventContract = new EventContract(container); | |
| const dispatcher = new EventDispatcher(invokeRegisteredListeners); | |
| registerDispatcher(eventContract, dispatcher); | |
| eventDelegation.eventContract = eventContract; | |
| }; |
I've also updated the function to init EventContract if needed. We can use this function later in the client-only code path. WDYT?
There was a problem hiding this comment.
i was a little afraid of order of operations in the case both eventReplay() and withGlobalEventDelegation() are available. I did initialize the event contract though.
8e56dc1 to
eb46d58
Compare
There was a problem hiding this comment.
LGTM
I'm comfortable with these changes after some discussion with @iteriani.
reviewed-for: fw-core, fw-platform-server, public-api, primitives
AndrewKushnir
left a comment
There was a problem hiding this comment.
LGTM, just one comment with a refactoring proposal.
AndrewKushnir
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
…that will be used with global event delegation. This also moves the code that stashes the jsaction more closely to the code that actually sets the event listener.
eb46d58 to
5406104
Compare
|
TESTED=TGP Failing tests appear unrelated |
|
This PR was merged into the repository by commit 6e89ef1. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |


This also moves the code that stashes the jsaction more closely to the code that actually sets the event listener. I've considered just moving that code to the listener itself..but it's in a different package. Maybe we need to add another DomEventsPlugin implementation?
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