0

I'm using library and handle event from library (for example onUpgrade). The problem is that this event can be called very often, therefore I need handle my onUpgrade event with debounce 3 seconds. Please help me how can this be done? I used already Rx java debounce, but with edit text, and I don't understand how it can be applied to an event onUpgrade from the library.

onUpgrage: (Data) -> Unit
testivanivan
  • 967
  • 13
  • 36
  • Without code it would be difficult to offer the solution. I assume your ```onUpgrade``` calls are not wrapped as ```Observable``` objects, also it is not clear how do you process this data next. You might create data member field, update on your ```onUpgrade``` call, but read this data from other parts of your application by wrapping it into ```Observable``` object, e.g. https://reactivex.io/documentation/operators/just.html – Gleichmut Jan 30 '23 at 08:25
  • Convert the callback to an Observable using `Observable.create()`. Then you can use `debounce()` on it. https://github.com/mgp/effective-rxjava/blob/master/items/convert-callbacks-to-observable.md https://stackoverflow.com/questions/42118782/replace-callbacks-with-observables-from-rxjava – Tenfour04 Jan 30 '23 at 14:36

0 Answers0