JSFiddle - React, Tailwind, and code Playground

by Jerry Hong

HTML

<script src="https://unpkg.com/@reactivex/[email protected]/dist/global/Rx.umd.js"></script>

CSS

html, body {
  height: 100%;
}

JavaScript

var source = Rx.Observable.timer(1000, 1000);

// 取得 subscription
var subscription = source.subscribe({
	next: function(value) {
		console.log(value)
	},
	complete: function() {
		console.log('complete!');
	},
	error: function(error) {
    console.log('Throw Error: ' + error)
	}
});

setTimeout(() => {
    subscription.unsubscribe();// 停止訂閱(退訂)
}, 5000);