Created
March 1, 2015 00:13
-
-
Save kdeloach/52e7b5dd896aafef724a to your computer and use it in GitHub Desktop.
Bacon test case
This file contains hidden or 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
<html> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
<script type="text/javascript" src="dist/Bacon.js"></script> | |
<body> | |
<p>Ready</p> | |
<script type="text/javascript"> | |
var SENTINEL = {}, | |
resetBus = new Bacon.Bus(), | |
letterStream = $('body').asEventStream('keypress') | |
.map('.keyCode') | |
.map(String.fromCharCode), | |
wordProp = letterStream.merge(resetBus.map(SENTINEL)) | |
.scan('', function(acc, letter) { | |
return letter === SENTINEL ? '' : acc.concat(letter); | |
}) | |
.debounce(250) | |
.filter('.length') | |
.doAction(resetBus, 'push'); | |
wordProp.doAction(handle).log('word'); | |
function handle() { | |
throw 'Error'; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment