wrist

0.0.3 • Public • Published

wrist Build Status Coverage Status

An easy way to bind or react to properties change.

It also works with input elements and their value too.

const watcher = wrist.watch(
  // generic Object or DOM element
  generic,
  // the property name to watch
  'propertyName',
  // the callback that will trigger
  // only when property value changes
  function cb(propName, oldVal, newVal) {
    this === generic; // true
    propName;         // "propertyName"
  }
);
 
// to drop a watcher
watcher.unwatch();
 
// or via unwatch and same watch signature
wrist.unwatch(generic, 'propName', cb);

Each property can have more than one callback registered.

Dual bindings do not interfere with each other.


(C) 2017 Andrea Giammarchi - MIT Style License

Package Sidebar

Install

npm i wrist

Weekly Downloads

46

Version

0.0.3

License

MIT

Last publish

Collaborators

  • webreflection