Skip to content

Instantly share code, notes, and snippets.

@luislobo14rap
Created December 25, 2019 00:03
Show Gist options
  • Save luislobo14rap/476e3fe7e2b5690ef479c2f072145978 to your computer and use it in GitHub Desktop.
Save luislobo14rap/476e3fe7e2b5690ef479c2f072145978 to your computer and use it in GitHub Desktop.
if-this-type-changes.js
// if-this-type-changes.js v1
function ifThisTypeChanges(observed, callback, scope = window) {
let originalType = typeof scope[observed];
let interval = setInterval(function() {
let newType = scope[observed];
if (originalType != newType) {
clearInterval(interval);
callback(originalType, newType);
};
}, 10);
};
// ifThisTypeChanges.min.js v1
function ifThisTypeChanges(a,b,c=window){let d=typeof c[a],e=setInterval(function(){let f=c[a];d!=f&&(clearInterval(e),b(d,f))},10)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment