# DebouncedBuffer With RxJava

DevFeed: [DebouncedBuffer With RxJava](<https://devfeed.tech/articles/debouncedbuffer-with-rxjava-25242.md>)

Original publisher: [Read original article](<https://kau.sh/blog/debouncedbuffer-with-rxjava/>)

Author: Kaushik Gopal

Published: 2015-01-05T07:00:00Z

Content type: tutorial

Language: en

Sources: [Kaushik Gopal's Site](<https://devfeed.tech/sources/kaushik-gopal-s-site.md>)

Topics: [RxJava](<https://devfeed.tech/topics/rxjava.md>), [Code](<https://devfeed.tech/topics/code.md>), [implementation](<https://devfeed.tech/topics/implementation.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>)

## AI overview

This tutorial explores how to approximate a debouncedBuffer operator in RxJava. It explains why debounce and buffer alone do not meet the requirement of collecting emitted items only after a quiet period, and introduces a boundary-observable approach.

## Source excerpt

This is a bonus RxJava post that I landed up writing along with my previous post on creating an event bus with RxJava. If you went through the code in the actual repo you would have noticed more than one version of the bottom fragment in the RxBus demo. Originally I envisioned the RxBus example being a tad bit fanicer however as I coded up the example, I realized that too many concepts were getting conflated. The ridiculous simplicity of the RxBus implementation was lost. So I dumbed down the original example but left in the original code for the Rx padawans. Original example: Fancier one: The fanciness is basically in the numbers being accumulated and shown in "chunks". In my head I thought I could simply use the debounce operator (like the debounce search example) and be on my jolly way, but this was not to be... From the always helpful RxJava wiki: debounce - only emit an item from the source Observable after a particular timespan has passed without the Observable emitting any other items I wanted the "after a particular timespan has passed without the Observable emitting any other items" part of debounce, but I needed the whole list of emitted items (not just a single item). Thebufferoperator also seemed promising: buffer - periodically gather items from an Observable into bundles and emit these bundles rather than emitting the items one at a time "emit as bundles", perfect! uh... not exactly, it says "periodically" and that literally means periodically. So EVERY X seconds/minutes it will emit a list of objects regardless of whether there were any taps/events. This would mean a bunch of empty lists would periodically be emitted when no taps were registered. I could get the example working if I tweaked the time component for buffer just enough and filter out the empty results, but it was a hack and not the way of the Rx. What I really needed was a selective combination of debounce and buffer - a "debouncedBuffer" operator. Such an operator doesn't exist but you could