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

Review TBlEventTarget #702

Open
tinchodias opened this issue Feb 19, 2025 · 1 comment
Open

Review TBlEventTarget #702

tinchodias opened this issue Feb 19, 2025 · 1 comment

Comments

@tinchodias
Copy link
Collaborator

In short, this trait implements the API of the subject (or publisher) in the Observer Design Pattern, specialized on Bloc elements. This API could directly belong to BlElement, but it exists as a trait so other objects can benefit, being polymorphic with an element.

=> First critic: This may be wrong/misleading... See #355, for example.

The only requirement from this trait is eventDispatcher, where each user can choose from 3 available dispatchers.

The trait comment can be improved. It says: "I implement a basic infrastructure of event management. Any object that needs to be able to handle events should use me.".

The API has:

  • hasNextEventTarget and nextEventTarget hooks, that are overridden by BlElement to create a BlEventDispatcherChain with the parent elements up to the root.
  • add/remove/access handlers (subscribers)
  • add/remove/access filters (high-priority subscribers)
  • add/remove/access shortcuts (subscribers to keyboard events)

=> Second critic: Do we need the name "filters" to differentiate event handlers that have a higher-priority from the ones with regular-priority? they are mostly used in debugging and testing code. Maybe something like addHandlerFirst: and addHandlerLast: are enough.

=> Third critic: Shortcuts API narrows the meaning of TBlEventTarget... users should only be publishers that may dispatch keyboard events.

@tinchodias
Copy link
Collaborator Author

tinchodias commented Feb 19, 2025

These are the users of TBlEventTarget:
Image

I consider almost all of them don't fit with the meaning of TBlEventTarget. Almost all only need an Announcer. Even BlSpace, I'm not sure it needs to be a user. We removed some addChild* API in BlSpace that was making it partially polymorphic with BlElement. We removed it because it was only redirecting the message to the space's root. So it may be a similar case with TBlEventTarget in space.


EDIT: the other option is to remove shortcut API from TBlEventTarget to make it more general, and then it would make sense to have all those users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant