JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15398
  • Score
    100M100P100Q157161F
  • License MIT

Decouple the DOM events from expensive functions.

Package Exports

  • decouple

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (decouple) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

decouple

NPM version License Build status Coverage Status Dependency status devDependency status downloads

Decouple the DOM events from expensive functions.

Based on

Installation

$ npm install decouple

$ bower install decouple

$ spm install decouple

$ component install pazguille/decouple

Usage

function foo(event) {
  console.log('foo');

  // The function receive the scroll event as parameter.
  console.log(event);

  // The function context is the given node.
  console.log(this.scrollTop);
}

function bar() {
  console.log('bar');
}

decouple(document.querySelector('#box'), 'scroll', foo);

API

decouple(node, event, listener)

Decouple the DOM event from the listener on give node. Returns the listener handler.

  • node {HTMLElement} - A given HTMLElement.
  • event {String} - A given DOM event.
  • listener {Function} - A given listener to execute when the given event is fired.
decouple(window, 'scroll', fn);

With ❤ by

License

MIT license. Copyright © 2016.