Skip to content

Latest commit

 

History

History
38 lines (31 loc) · 788 Bytes

README.md

File metadata and controls

38 lines (31 loc) · 788 Bytes

eardrum.js

A Javascript library that binds event listeners to object properties Preview

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