eardrum
v1.0.0
Published
A Javascript library that binds event listeners to object properties
Downloads
2
Maintainers
Keywords
Readme
eardrum.js
A Javascript library that binds event listeners to object properties
Basic API
Documentation in progress ...
Use case examples
const app = {
// ...
appErrorLogger: null
};
eardrum.watch({
object: app,
property: 'appErrorLogger',
listener: {
target: window,
type: 'error'
}
});
// No event listener is added so far,
// but eardrum watches appErrorLogger property
// Assigning a function to watched property
app.appErrorLogger = function logger (event) {
console.log(event);
};
// ==> eardrum adds an event listener
// (logger will be used to handle onerror events)
// Assigning back non function value to wached property
app.appErrorLogger = null;
// ==> Event listener is removed by eardrum