-
Notifications
You must be signed in to change notification settings - Fork 0
[URH-14] useTimer 신규 #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
callbackRef.current = callback; | ||
}, [callback]); | ||
|
||
useUnmountEffect(clearActiveTimer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥺 갬둥..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤩 천재만재
(async () => { | ||
cancelTokenRef.current = { isCancelled: false }; | ||
timerRef.current = delayExecution(ms); | ||
|
||
await timerRef.current.start(cancelTokenRef.current); | ||
callbackRef.current(); | ||
})(); | ||
}, [ms]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(async () => { | |
cancelTokenRef.current = { isCancelled: false }; | |
timerRef.current = delayExecution(ms); | |
await timerRef.current.start(cancelTokenRef.current); | |
callbackRef.current(); | |
})(); | |
}, [ms]); | |
cancelTokenRef.current = { isCancelled: false }; | |
timerRef.current = delayExecution(ms); | |
timerRef.current.start(cancelTokenRef.current).then(() =>{ | |
callbackRef.current(); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P4] 아니믄
cosnt startTimer = async () => {
clearActiveTimer(); // 기존 타이머 취소
cancelTokenRef.current = { isCancelled: false };
timerRef.current = delayExecution(ms);
await timerRef.current.start(cancelTokenRef.current);
callbackRef.current();
}
const startHandler = useCallback(() => {
startTimer();
},[ms]);
이렇게는 어떠세요?
IIFE가 있는게 가독성이 안좋은거 같아서요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
짧은 IIFE는 오히려 쉽게 로직이 읽을 수 있을 거 같기도 한데 다른 분들 의견도 궁금하네요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useTimer가 머지되면 useDelayFlag에도 적용해 봐야겠어요!🔥
👾 Pull Request
1️⃣ Spec
2️⃣ 변경 사항
3️⃣ 예시 코드
4️⃣ 관련 문서 (선택 사항)