-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Fix/#130] : 1차 스프린트 2차 QA 반영 #131
Conversation
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.
throttle 테스트 해봤는데 톡으로 보낼게요!
private val lastCalls = mutableMapOf<String, Long>() | ||
|
||
fun debounce( | ||
delayTime: Long = DEBOUNCE_DELAY, | ||
coroutineScope: CoroutineScope, | ||
event: () -> Unit, | ||
) { | ||
if (::debounceJob.isInitialized) debounceJob.cancel() | ||
debounceJob = coroutineScope.launch { | ||
delay(delayTime) | ||
event() | ||
fun canProceed(key: String): Boolean { | ||
val currentTime = System.currentTimeMillis() | ||
val lastCallTime = lastCalls[key] ?: 0L | ||
return if (currentTime - lastCallTime >= THROTTLE_DELAY) { | ||
lastCalls[key] = currentTime | ||
true | ||
} else { | ||
false | ||
} | ||
} | ||
|
||
companion object { | ||
private const val DEBOUNCE_DELAY = 200L | ||
private const val THROTTLE_DELAY = 2000L | ||
|
||
fun from(): SingleEventHandler = SingleEventHandler() | ||
} |
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.
thorttle 보단 싱글 클릭에 가깝다고 생각이 되서 저도 한번 테스트 해보고 말씀드려 볼게요!
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.
흠 싱글클릭이 최선인 것 같습니다
throttle을 flow랑 라이프사이클로 구현했는데 뷰의생명주기를 따라가야해서 어쩔수 없네요..
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.
😂
✅ 𝗖𝗵𝗲𝗰𝗸-𝗟𝗶𝘀𝘁
📌 𝗜𝘀𝘀𝘂𝗲𝘀
📎𝗪𝗼𝗿𝗸 𝗗𝗲𝘀𝗰𝗿𝗶𝗽𝘁𝗶𝗼𝗻
20241127_215432.mp4
📷 𝗦𝗰𝗿𝗲𝗲𝗻𝘀𝗵𝗼𝘁
comment dialog, hidekeyboard
KakaoTalk_20241127_221536004.mp4
💬 𝗧𝗼 𝗥𝗲𝘃𝗶𝗲𝘄𝗲𝗿𝘀