Skip to content

Review TBlEventTarget #702

Open
Open
@tinchodias

Description

@tinchodias

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions