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
const globalState = {}; | |
const subscribe = (key, className, observer) => globalState[key]._observers.set(className, observer); | |
const unsubscribe = (key,className,observer) => globalState[key]._observers.remove(className, observer); | |
const _notify = (key) => globalState[key]._observers.forEach((observer) => observer()); | |
const initState = ({ key, defaultValue }) => { | |
if (key in globalState) throw Error('이미 존재하는 key값 입니다.'); |
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
export const debounce = debounceInit(); | |
//될지는 모르겠음 | |
const debounce = (fn,wait) => { | |
let timer = null; | |
function debounced(){ | |
if (timer) clearTimeout(timer); | |
timer = setTimeout(fn, wait); | |
} | |
return debounced; |