Skip to content

Extract IMouseListener - #583

Open
Wagner-Laranjeiras wants to merge 1 commit into
eclipse-sprotty:mainfrom
Wagner-Laranjeiras:wagner-laranjeiras/478/extract-imouse-listener
Open

Wagner-Laranjeiras wants to merge 1 commit into
eclipse-sprotty:mainfrom
Wagner-Laranjeiras:wagner-laranjeiras/478/extract-imouse-listener

Conversation

@Wagner-Laranjeiras

Copy link
Copy Markdown
Contributor

Extract IMouseListener so MouseTool is not tied to the convenience class

What

  • Adds an IMouseListener interface covering all mouse handlers plus decorate. MouseListener now implements it.
  • MouseTool and PopupMouseTool now accept IMouseListener[] instead of MouseListener[], including in register/deregister.
  • Reuses the existing TYPES.MouseListener token, so current bindings keep working and a second token can't cause double dispatch.
  • Fixes a latent bug: .reduce((a, b) => a.concat(b)) threw a TypeError when no mouse listeners were registered. It now has an initial [].

Why

MouseTool depended on the concrete MouseListener class. Listeners could not be written without extending it, and the tool is now consistent with the existing ITouchListener approach.

Compatibility

Non-breaking. MouseListener is unchanged in behaviour and still implements all handlers. Existing subclasses and bindings work as before.

Testing

  • New mouse-tool.spec.ts builds real Inversify containers. It covers:
    • dispatch to IMouseListener implementations that don't extend MouseListener
    • register/deregister
    • the empty-listener case
  • npm run build, npm run lint (0 errors) and npm test (364 tests) pass.

Closes #478

Reuse TYPES.MouseListener so existing bindings keep working and a second token cannot double-dispatch.

Signed-off-by: Wagner Laranjeiras <wagner.laranjeiras@typefox.io>

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

Extract IMouseListener

1 participant