Observable connect

In this example below you will see how to do a Observable connect with some HTML / CSS and Javascript

This awesome code was written by 1kohei1, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 1kohei1 ©


  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

  <meta charset="UTF-8">
  <title>Observable connect</title>
      <link rel="stylesheet" href="css/style.css">



  <div id="myWindow">
  <button id="subscribe">Subscribe</button>
  <button id="unsubscribe">Unsubscribe</button>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/rxjs/5.5.5/Rx.js'></script>


    <script  src="js/index.js"></script>



/*Downloaded from https://www.codeseek.co/1kohei1/observable-connect-QORxeV */
body, #myWindow {
  height: 1000px;

/*Downloaded from https://www.codeseek.co/1kohei1/observable-connect-QORxeV */
const a = document.getElementById("myWindow");
const b = document.getElementById("subscribe");
const c = document.getElementById("unsubscribe");

const x$ = Rx.Observable.fromEvent(a, 'mousemove')

const y$ = Rx.Observable.fromEvent(b, 'click');
const z$ = Rx.Observable.fromEvent(c, 'click');

let sub = null;

y$.subscribe(() => {
  sub = x$.subscribe(e => console.log(e));
z$.subscribe(() => {