Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.6/rx.all.js"></script>
</head>
<body>
<div id="app">
</div>
</body>
</html>
 
function main(DOMSource) {
  const click$ = DOMSource;
  return {
    DOM: click$
      .startWith(null)
      .flatMapLatest(() => 
        Rx.Observable.timer(0, 1000)
          .map(i => `Seconds Elapsed ${i}`)
      ),
    Log: Rx.Observable.timer(0, 2000)
      .map(i => 2 * i)
  };
}
function DOMDriver(text$) {
  text$.subscribe(text => {
    $app = document.querySelector('#app');
    $app.textContent = text;
  });
  const DOMSource = Rx.Observable.fromEvent(document, 'click');
  return DOMSource;
}
function consoleLogDriver(msg$) {
  msg$.subscribe(msg => {
    console.log(msg);
  });
}
const drivers = {
  DOM: DOMDriver,
  Log: consoleLogDriver
};
function run(main, drivers) {
  const proxyDOMSource = new Rx.Subject();
  const sink = main(proxyDOMSource);
  const DOMSource = DOMDriver(sink.DOM);
  DOMSource.subscribe(click$ => proxyDOMSource.onNext(click$));
//   Object.keys(drivers).forEach(key => {
//     drivers[key](sink[key])
//   });
}
run(main, drivers);
Output

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

Dismiss x
public
Bin info
yoyoyohamapipro
0viewers