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

Explicit event API #2008

Merged
merged 30 commits into from
Apr 11, 2019
Merged

Explicit event API #2008

merged 30 commits into from
Apr 11, 2019

Conversation

Tyriar
Copy link
Member

@Tyriar Tyriar commented Apr 10, 2019

This PR exposes the new explicit events API that will replace the old node-like EventEmitter. I've converted all internal events over to the new EventEmitter2, the only usage of EventEmitter remaining is within Terminal to refire the events so we don't break compatibility until v4.

Some of the events have changes a little or been removed, see below:

  • blur -> Removed as you can just listen to the DOM event on Terminal.textarea
  • focus -> Removed as you can just listen to the DOM event on Terminal.textarea
  • linefeed -> onLineFeed
  • selection -> onSelectionChange
  • data -> onData
  • key -> onKey
  • keypress -> Removed in favor of a single onKey
  • keydown -> Removed in favor of a single onKey
  • refresh -> onRender
  • resize -> onResize
  • scroll -> onScroll
  • title -> onTitleChange

New events being added:

  • onCursorMove, this was already being used by the search addon and also within VS Code

If anyone sees events they rely upon removed please let me know how you're using it as on is now deprecated and will be removed soon.

Fixes #1505

@Tyriar Tyriar added this to the 3.13.0 milestone Apr 10, 2019
@Tyriar Tyriar self-assigned this Apr 10, 2019
@Tyriar Tyriar merged commit fa70aa0 into xtermjs:master Apr 11, 2019
@Tyriar Tyriar deleted the event_emitter_2 branch April 11, 2019 16:08
@Tyriar Tyriar mentioned this pull request May 10, 2019
10 tasks
@vincentwoo
Copy link
Contributor

If .off is deprecated, is there a new way to remove event listeners now?

@Tyriar
Copy link
Member Author

Tyriar commented May 16, 2019

@vincentwoo onData, etc. return an IDisposable. Hold on to that and call .dispose() on it to remove the listener.

@vincentwoo
Copy link
Contributor

oh ho ho ho, fancy

@Tyriar
Copy link
Member Author

Tyriar commented May 16, 2019

😎

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.

Replace IEventEmitter in API with explicit handlers
2 participants