Skip to content

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.

License

Notifications You must be signed in to change notification settings

ChartBoost/changes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Changes

Build Status Code Climate

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.

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();

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published