Created
December 25, 2019 00:03
-
-
Save luislobo14rap/476e3fe7e2b5690ef479c2f072145978 to your computer and use it in GitHub Desktop.
if-this-type-changes.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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