I know that there is an easy way to do this - but it has beaten me tonight ...
I want to know if two events occur within 300 milliseconds of each other, as in a double click.
Two leftdown mouse clicks in 300 milliseconds - I know this is what the reactive framework was built for - but damn if I can find a good doc that has simple examples for all the extenstion operatores - Throttle, BufferWithCount, BufferWithTime - all of which just werent' doing it for me....
Edit - Use
TimeInterval()
instead.The
Zip() and Timestamp()
operators might be a good start.Probably best to test this via the test scheduler, so you know exactly what you're getting:
The
TimeInterval
method will give you the time between values.If you want to be sure that triple clicks don't trigger values, you could just use
Repeat
on a hot observable (I've used aFastSubject
here as the clicks will all come on one thread and therefore don't require the heaviness of the normal Subjects):