목록Throttling (1)
뉴히의 개발 로그
[TIL] 20230709 - Throttling & debouncing / lodash 라이브러리
[ Throttling ] Leading Edge : 이벤트가 일어난 첫번째에 function을 일으킴 Trailing Edge : 이벤트가 일어났을 때 어느정도 Delay를 두고 마지막에 function을 일으킴 Leading & Trailing Edge : dealy의 처음과 마지막에 function을 일으킴 const throttle = (delay) => { if (timerId) { // timerId가 있으면 바로 함수 종료 return; } setState(!state); console.log(`API요청 실행! ${delay}ms 동안 추가요청 안받음`); timerId = setTimeout(() => { console.log(`${delay}ms 지남 추가요청 받음`); timerId ..
개발일지/TIL
2023. 7. 9. 19:57