Created
October 15, 2024 21:01
-
-
Save naosim/63d386edc554384dc9d5b36a90d2aa47 to your computer and use it in GitHub Desktop.
変更を監視する
This file contains 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
class ChangeEventChecker { | |
add(name, checkerFunc) { | |
this[name] = {checkerFunc, lastValue:undefined, isChanged:false}; | |
return this; | |
} | |
check() { | |
Object.entries(this).forEach((e) => { | |
const [k, v] = e; | |
const value = v.checkerFunc(); | |
if(v.lastValue !== undefined) { | |
v.isChanged = v.lastValue != value; | |
} | |
v.lastValue = value; | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
本クラスを使う場合