Hello everyone. I have two buttons which can be cl...
# rx
u
Hello everyone. I have two buttons which can be clicked at the same time. I would like to get notified on the event of the button that was clicked first in this case, the second event must be ignored. What operator should I use in this case? I use RxBinding events.
m
r
yep amb is the operator you’re looking for
u
I forgot to mention that I'd like to receive an event from one of the buttons within the timespan of 400 milliseconds. Then again user can click two buttons and i'll receive new event from one of the buttons (the one that was clicked first), and so on. @rakeeb, @martinsumera, thanks. I checked amb and it seems to emit all of the items of the observable that was triggered first, while I need only one event from one of the observables at a time within a certain timespan.
m
Copy code
Observable.merge(first, second)
   .throttleFirst(400, TimeUnit.MILLISECONDS)
I think that this should solve your problem
u
@martinsumera, 💥