Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Created February 17, 2010 00:35
Show Gist options
  • Save mattpodwysocki/306133 to your computer and use it in GitHub Desktop.
Save mattpodwysocki/306133 to your computer and use it in GitHub Desktop.
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="rx.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
var click = Rx.Observable.FromHtmlEvent($("#scanButton").context, "click");
var dblClick = Rx.Observable.FromHtmlEvent($("#scanButton").context, "dblclick");
var clickAggregate = click.Merge(dblClick).Scan(0, function(acc, x) {
return acc + 1;
});
clickAggregate.Subscribe(function(times) {
$("#results").html("Clicked " + times + " times");
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment