https://github.com/chartboost/changes
The `Changes` module allows you to inspect an object on an interval, firing a callback when the value is different than its last recorded state. Useful for observing objects that don't emit events or would be better to check at regular intervals. Examples: browser location, scroll position, etc.
https://github.com/chartboost/changes
Last synced: over 1 year ago
JSON representation
The `Changes` module allows you to inspect an object on an interval, firing a callback when the value is different than its last recorded state. Useful for observing objects that don't emit events or would be better to check at regular intervals. Examples: browser location, scroll position, etc.
- Host: GitHub
- URL: https://github.com/chartboost/changes
- Owner: ChartBoost
- License: mit
- Created: 2014-02-11T21:55:06.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-02-24T04:55:35.000Z (over 11 years ago)
- Last Synced: 2024-12-18T17:01:54.320Z (over 1 year ago)
- Language: CoffeeScript
- Homepage:
- Size: 103 KB
- Stars: 0
- Watchers: 178
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Changes
[](https://travis-ci.org/markazevedo/changes) [](https://codeclimate.com/github/markazevedo/changes)
The `Changes` module allows you to inspect an object on an interval, firing a callback when the value is different than its last recorded state. Useful for observing objects that don't emit events or would be better to check at regular intervals. Examples: browser location, scroll position, etc.
```js
var Changes = require('changes');
// Function for checking if browser url has changed
var checkUrl = function() {
return document.location.href;
};
// Executed when change is observed
var whenChanged = function(oldUrl, newUrl) {
console.log('Url changed from '+oldUrl+' to '+newUrl);
};
// Observer object created and started
var urlObserver = new Changes(checkUrl, whenChanged);
urlObserver.start();
```