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

[base-controller] ControllerMessenger should prohibit retroactive subscriptions to published events #4700

Open
MajorLift opened this issue Sep 13, 2024 · 0 comments
Labels

Comments

@MajorLift
Copy link
Contributor

MajorLift commented Sep 13, 2024

Motivation

Listeners in typical event systems like EventEmitter only trigger if they existed when the event was emitted. However, the messenger event pubsub system in our ControllerMessenger class does not follow this norm. This behavior should be fixed for maintenance and predictability reasons.

Acceptance Criteria

  • Subscribers should receive events only if they were already registered to the event at the time it was published.
  • After a given event has been published, its subscribers collection should not be retroactively mutated.
    • Eliminate the risk of a mutable subscribers collection triggering an infinite loop in React/Redux due to a circular dependency (e.g. a subscription handler mutates a hook dependency, which re-triggers its subscription).

Further Research

  • Consider introducing "Topics" for a collection of events that may need to be published repeatedly, potentially to a growing list of subscribers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant