Skip to content

chore: add eventListenerService [WPB-23186]#21000

Draft
e-maad wants to merge 2 commits intodevfrom
chore/add-event-listener-service-WPB-23186
Draft

chore: add eventListenerService [WPB-23186]#21000
e-maad wants to merge 2 commits intodevfrom
chore/add-event-listener-service-WPB-23186

Conversation

@e-maad
Copy link
Copy Markdown
Contributor

@e-maad e-maad commented Apr 15, 2026

StoryWPB-23186 [Web] Applock forgot password - Users prompted to log out, log in, set new applock password

Summary

Add eventListenerService for purify functions and pass window.eventListener as a dependency.

Security Checklist (required)

  • External inputs are validated & sanitized on client and/or server where applicable.
  • API responses are validated; unexpected shapes are handled safely (fallbacks or errors).
  • No unsafe HTML is rendered; if unavoidable, sanitization is applied and documented where it happens.
  • Injection risks (XSS/SQL/command) are prevented via safe APIs and/or escaping.

Accessibility (required)

Standards Acknowledgement (required)


Screenshots or demo (if the user interface changed)

Notes for reviewers

  • Trade-offs:
  • Follow-ups (linked issues):
  • Linked PRs (e.g. web-packages):

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 15, 2026

🔗 Download Full Report Artifact

🧪 Playwright Test Summary

  • Passed: 14
  • Failed: 0
  • Skipped: 0
  • 🔁 Flaky: 0
  • 📊 Total: 14
  • Total Runtime: 754.6s (~ 12 min 35 sec)

@sonarqubecloud
Copy link
Copy Markdown

const index = current.indexOf(entry);

if (index !== -1) {
current.splice(index, 1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mutating the same array inside a loop will skip the some array elements.
[eventOnce, event1, event2]
if you remove eventOnce after the first iteration then event1 will be skipped in the second iteration as it will be on index 0 and on index 1 it will be event2.
So we can store the events to be removed on another array and delete it after the loop.

@screendriver
Copy link
Copy Markdown
Member

screendriver commented Apr 17, 2026

I'm not convinced this module is a useful abstraction in its current form. To me this reads more like a generic event-emitter-style wrapper than a clean architecture boundary. eventListenerService is essentially a thin wrapper around global event APIs and deterministicEventListenerService adds another generic listener layer on top, but without making the domain model clearer.

I also find the name deterministic misleading here. In this context, determinism usually refers to controlling sources of runtime variability such as time, network responses, randomness, retries, or scheduling. This implementation does not seem to address that kind of nondeterminism; it mainly provides synchronous in-memory listener dispatch.

I'm also concerned about the typing. Accepting arbitrary string event names and generic Event values means the compiler cannot help us validate that subscriptions and dispatched payloads actually match.

My preference would be to keep global/browser event registration at the application entry point and pass concrete function callbacks inward into the application layer. That keeps the browser-specific wiring at the edge, makes dependencies explicit and gives us better type safety than introducing a generic event-listener abstraction.

@e-maad e-maad marked this pull request as draft April 27, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants