Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
<html>
<head>
<meta charset="UTF-8"></meta>
<title>Events</title>
<script type="text/javascript" src="../../dist/js-csp.min.js"></script>
</head>
<body>
<div id="display"></div>
<script type="text/javascript">
var el = document.getElementById("display");
function show(text) {
el.textContent = text;
console.log(text);
}
function noOp() {};
function firehose(element, eventName) {
var ch = csp.chan(csp.buffers.dropping(1));
element.addEventListener(eventName, function(event) {
csp.putAsync(ch, event, noOp);
});
return ch;
}
var moves = firehose(document.body, "mousemove");
csp.go(function*() {
for (;;) {
var event = yield csp.take(moves);
show(event.x + ":" + event.y);
for (;;) {
var result = yield csp.alts([moves, csp.timeout(50)]);
var value = result.value;
if (value === csp.CLOSED) {
show("STOP");
break;
}
event = value;
show(event.x + ":" + event.y);
}
}
});
</script>
</body>
</html>