https://github.com/mrsteele/observe.js
Listen to the console
https://github.com/mrsteele/observe.js
Last synced: 3 months ago
JSON representation
Listen to the console
- Host: GitHub
- URL: https://github.com/mrsteele/observe.js
- Owner: mrsteele
- License: mit
- Created: 2015-09-22T19:33:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-28T01:13:52.000Z (over 9 years ago)
- Last Synced: 2024-12-28T08:40:58.155Z (5 months ago)
- Language: JavaScript
- Size: 152 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# observe.js
True observations### What is observe.js?
observe.js allows you to listen to any object for whenever any changes occur, as well as when any function fires.
This is done by wrapping around the original object and firing events between commands.### How do I listen to an object?
Easy!
```
// first apply the listener...
observe(console)// then wait for events...
console.on("log", function (msg) {
alert('The console says: ' + msg);
});
```You can also listen to property changes with the native `Object.observe`!
```
// the object to listen to
var test = {msg: "hello"};// apply the listener
observe(test);/// listen to the property name to observe changes
test.on("msg", function (oldValue) {
alert("'msg' changed from '" + oldValue + '" to '" + test.msg + "'!");
});```
### I wanna contribute
Yes please! Pull request and code away!