Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <script src="https://github.com/ysmood/yaku/releases/download/0.15.9/yaku.browser.full.min.js"></script>
</head>
<body>
    <button id="btn">button</button>
    <div id="display01">single click: </div>
    <div id="display02">double click: </div>
</body>
</html>
 
// For API, goto: https://github.com/ysmood/yaku#observableexecutor
let Promise = Yaku;
let { Observable, never } = Yaku;
let singleClick = new Observable(next => btn.onclick = next);
let doubleClick = singleClick.subscribe(debounceClick());
singleClick.subscribe(count(display01));
doubleClick.subscribe(count(display02));
// ************* Common Helpers **************
function count (elem) {
    return () => elem.innerText += " + ";
}
function debounceClick () {
    let last = new Date();
    return () => {
        let now = new Date();
        if (now - last > 300) {
            last = now;
            return never();
        } else {
            last = 0;
        }
    };
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
ysmoodpro
0viewers