Stimulus Discourse

Listening to custom (not jQuery) events


#1

How would I listen to custom JS events emitted by third-party code? I want to listen to Quill events

Have reviewed jQuery events and callbacks but they both seem a bit hacky.

Emitter.events = {
  EDITOR_CHANGE        : 'editor-change',
  SCROLL_BEFORE_UPDATE : 'scroll-before-update',
  SCROLL_OPTIMIZE      : 'scroll-optimize',
  SCROLL_UPDATE        : 'scroll-update',
  SELECTION_CHANGE     : 'selection-change',
  TEXT_CHANGE          : 'text-change'
};
Emitter.sources = {
  API    : 'api',
  SILENT : 'silent',
  USER   : 'user'
};


export default Emitter;

#2

Javan wrote about this in his post in this thread: One of two actions on same element not being called