Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (47 sloc) 1.62 KB
<script src="../lib/jquery.js"></script>
<script src="../dist/Bacon.js"></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"))
keyState(32).onValue(function(state) {
function isEmpty(s) { return s.length == 0 }
$("#enabling input").asEventStream("keyup").map(function(event) { return $(}).toProperty("").map(isEmpty).assign($("#enabling button"), "attr", "disabled")
<h1>bacon.js example page</h1>
<h2>Simplest example:</h2>
<span id="clikme">click me</span>
<h2>Combinators example</h2>
SPACEBAR status=<span id="state"></span>
<div id="enabling">
<input type="text" placeholder="required field">
<button>Don't push me</button>
Jump to Line
Something went wrong with that request. Please try again.