Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

consolidated-events

lencioni3.8mMIT2.0.2

Manage multiple event handlers using few event listeners

events, performance

readme

consolidated-events Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

Manage multiple event handlers using few event listeners.

Example

import { addEventListener } from 'consolidated-events';

const removeEventListener = addEventListener(
  window,
  'scroll',
  () => { console.log('scrolling') },
  { passive: true }
);

...

removeEventListener();

changelog

v2.0.1

  • Move TargetEventHandlers methods to prototype (#15)

v2.0.0

  • Now built with rollup (#8)
  • Deprecated removeEventListener export removed (#13)
  • Passive event listener test is now removed after being added (#11)
  • Reduced bundle size impact by replacing a class with a function (#12)

v1.1.1

  • Prevent event handlers from being mutated during current iteration.

v1.1.0

  • Return an unsubscribe function from addEventListener and deprecate removeEventListener.

v1.0.1

  • Fix bug with handleEvent().

v1.0.0

  • Initial release.