Detecting multi-clicks

Suppose you decided, for some reason or another, that users should be able to triple-click or four-click on something, and the number of clicks would somehow be meaningful and produce some kind of special result. Browsers do very well detecting single- or double-clicks and let you respond to them, but triple- (or more) clicks aren't available so easily. However, we can make do with a bit of FRP. Let's start with a really basic layout, including a text span that the user should click. The code is given here:

<html>  <head>    <title>Multiple click example</title>    <script type="text/javascript" src="rxjs.umd.js"></script>  </head>  <body>    <span id="mySpan">Click this text many times (quickly)</span>    <script>      // our code goes ...

Get Mastering JavaScript Functional Programming - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.