# cyclejs-fundamentals

Plunker example for cycleJS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div id="app"></div>
  
  <script src="https://unpkg.com/xstream@10.9.0/dist/xstream.js"></script>
  <script>window.xs=xstream.default</script>
  <script src="script.js"></script>
</body>
</html>
</html>
// Logic
function main() {
    return xs.periodic(1000)                       
            .fold(prev => prev + 1, 0)        
            .map(i => `Seconds elapsed: ${i}`)
}

function domDriver(text$) {
   text$.subscribe({
    next: str => {
        const elem = document.querySelector('#app');
        elem.textContent = str;
     }
    })  
}

function logDriver(msg$) {
    msg$.subscribe({
        next: msg => {
            console.log(msg);
        }
    })
}

const sink = main();
domDriver(sink);
logDriver(sink);