Closed Prakhar-Agarwal-byte closed 1 year ago
This works, but I'd like to get more information as to why you chose this particular architecture. At first glance it looks like the companion object is there to ensure there is only one instance of the class? Why was this solution preferred to using a Kotlinobject
?
In general, you can make it easier for reviewers to understand your approach if your PRs have a bit more information. Use the opening thread item to explain what you tried, where you found the solution, why it's better than other approaches, etc. As is, reviewers are just left wondering why this particular approach was chosen, and have to retrace your steps by themselves (Googling, chatGPT, ect.)
I think using Kotlin "object" here is better. The "companion object" that I used before also achieves the same result of creating a singleton. The "object" provides this functionality out of the box.
I took inspiration from #295 PR. First I am storing the last time a button was clicked, then when an event is raised again using the ClickHelper then it calculates the difference between the last time the event was raised and now. Only if the difference is more than 800ms the event is allowed to go through.
…within 800ms
Fixes #287