Skip to content

Instantly share code, notes, and snippets.


maxpert/DebouncerUsage.kt Secret

Created Aug 1, 2018
What would you like to do?
Coroutine Debouncer Usage
val debouncer = CoroutineDebouncer(ConcurrentHashMap())
* Gets list of menus for given restaurant ID
* @param id of the restaurant
* @return list of menu items
suspend fun getRestaurantMenus(id: Long) : List<Menu> {
val cached = cacheL1.get(id)
if (cached != null) {
return cached.toList();
val deferredFetch = debouncer.debounce("restaurant:$id") {
return deferredFetch.await()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.