Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 0.4.9
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (52 sloc) 1.783 kb
<script src="../lib/jquery.js"></script>
<script src="../dist/Bacon.js"></script>
$(function() {
function isEmpty(s) { return s.length == 0 }
function always(value) { return function() { return value }}
function keyCodeIs(keyCode) {
return function(event) { return event.keyCode == keyCode }
function keyDownEvents(keyCode) {
return $(document).asEventStream("keydown").filter(keyCodeIs(keyCode))
function keyUpEvents(keyCode) {
return $(document).asEventStream("keyup").filter(keyCodeIs(keyCode))
function keyStateProperty(keyCode) {
return keyDownEvents(keyCode).map(always("DOWN"))
.subscribe(function(event) { alert("mmmm... bacon!") })
.onValue(function(value) { $("#spacebar-value").text(value) })
$("#enabling input")
.map(function(event) { return $( })
.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 value=<span id="spacebar-value"></span>
<div id="enabling">
<h2>Enable/disable example:</h2>
<input type="text" placeholder="required field">
<button>Don't push me</button>
Jump to Line
Something went wrong with that request. Please try again.