Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: map-filter-to-…
Fetching contributors…

Cannot retrieve contributors at this time

49 lines (41 sloc) 1.27 kB
<html>
<head>
<script src="../lib/jquery.js"></script>
<script src="../lib/Bacon.js"></script>
<script>
$(function() {
$("#clikme").asEventStream("click").subscribe(function(event) {
alert("mmmm... bacon!")
})
function always(value) { return function() { return value }}
function keyCodeIs(keyCode) {
return function(event) { return event.keyCode == keyCode }
}
function keyDowns(keyCode) {
return $(document).asEventStream("keydown").filter(keyCodeIs(keyCode))
}
function keyUps(keyCode) {
return $(document).asEventStream("keyup").filter(keyCodeIs(keyCode))
}
function keyState(keyCode) {
return keyDowns(keyCode).map(always("DOWN"))
.merge(keyUps(keyCode).map(always("UP"))).toProperty("UP")
}
keyState(32).onValue(function(state) {
$("#state").text(state)
})
})
</script>
</head>
<body>
<h1>bacon.js example page</h1>
<div>
<h2>Simplest example:</h2>
<span id="clikme">click me</span>
</div>
<div>
<h2>Combinators example</h2>
SPACEBAR status=<span id="state"></span>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.