Created
February 17, 2010 00:35
-
-
Save mattpodwysocki/306133 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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