Skip to content

A utility class for debouncing high-frequency events in Android using Kotlin Coroutines.

Notifications You must be signed in to change notification settings

MilindAmrutkar/KotlinDebouncer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KotlinDebouncer

A utility class for debouncing high-frequency events in Android using Kotlin Coroutines.

Description

Debouncing ensures that high-frequency events (like rapid button clicks) trigger functionality only once in a specified time interval, instead of for each and every event. This can be especially useful for preventing redundant network requests, or avoiding interface glitches due to fast successive updates.

This KotlinDebouncer is a simple utility that can be used to debounce events in Android. It uses Kotlin Coroutines to manage asynchronous tasks effectively.

Usage

First, initialize the Debouncer with a CoroutineScope:

val debouncer = Debouncer(lifecycleScope)

Then, use the debounce method to debounce an event:

myButton.setOnClickListener {
    debouncer.debounce(300L) {
        // Handle button click after 300ms debounce
    }
}

About

A utility class for debouncing high-frequency events in Android using Kotlin Coroutines.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages