Skip to content

Instantly share code, notes, and snippets.

@davidgarsan
Created September 12, 2017 05:47
Show Gist options
  • Save davidgarsan/55c31d7547bf7e94fab04ff00db2c8b7 to your computer and use it in GitHub Desktop.
Save davidgarsan/55c31d7547bf7e94fab04ff00db2c8b7 to your computer and use it in GitHub Desktop.
var memoizeNewValue = function() {
var old = null;
return function(newVal){
if(newVal === old) {
return false;
} else {
old = newVal;
return true;
}
}
};
var isNewValue = memoizeNewValue(function(value) {});
if(isNewValue()) {
// Do something.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment