DEV Community

Arun Sasidharan
Arun Sasidharan

Posted on

Android Gotchas: Mystic Debounce

Debounce Operator

So debounce is a pretty cool operator in Rx. When you want to emit an item only after a certain amount of time has passed, debounce does that in a pretty simple way:

Testing Debounce

Now that you have solved your problem with debounce, it’s time to write a small test and set it in stone.

Hit ^R to run the test and 💥


Looks like our sweet little debounce operator runs on its own sweet little scheduler and our TestScheduler wasn’t able to override it. Only took an entire day to figure that out! 🤦‍

Rescue Time

Pass a scheduler to debounce

and use the TestScheduler to test.

Hit ^R to run the test and ʕ•ᴥ•ʔ

If you liked this post, share it and stay tuned for the next one!
Read other stuff I’ve written here.

Discussion (0)