Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/konapun/watcher.js

Add before/after method modifiers to your Javascript objects
https://github.com/konapun/watcher.js

Last synced: 22 days ago
JSON representation

Add before/after method modifiers to your Javascript objects

Awesome Lists containing this project

README

        

# Watcher
Add before/after method modifiers to your objects

This is just a project I did to play around with Function.apply and is not meant
to be used in production.

### Usage
```js
var myObj = {
sayHello: function(name) {
console.log("Hello, " + name);
}
};

var watchedObj = Watcher.watch(myObj);

watchedObj.before('sayHello', function(name) {
console.log("About to say hello...");
});
watchedObj.after('sayHello' function(name) {
console.log("You're a real nice person, " + name);
});

watchedObj.sayHello('konapun'); // writes "About to say hello..." "Hello, konapun" "You're a real nice person, konapun"
```