Skip to content

Instantly share code, notes, and snippets.

@chenxeed
Created March 20, 2017 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chenxeed/28388fa71c636843b7a90b40a0b23a69 to your computer and use it in GitHub Desktop.
Save chenxeed/28388fa71c636843b7a90b40a0b23a69 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<!-- put markup and other contents here -->
</body>
</html>
// write ES2015 code and import modules from npm
// and then press "Execute" to run your program
import xs from 'xstream';
import rx from 'rx-lite';
import $ from 'jquery';
const request = $.ajax({url: 'https://jsonplaceholder.typicode.com/posts/1' })
const xs$ = xs.fromPromise(request).addListener({next: resp => console.log('xs', resp) });
const rx$ = rx.Observable.fromPromise(request).subscribe( resp => console.log('rx', resp) );
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"xstream": "9.3.0",
"rx-lite": "4.0.8",
"jquery": "3.2.0"
}
}
'use strict';
var _xstream = require('xstream');
var _xstream2 = _interopRequireDefault(_xstream);
var _rxLite = require('rx-lite');
var _rxLite2 = _interopRequireDefault(_rxLite);
var _jquery = require('jquery');
var _jquery2 = _interopRequireDefault(_jquery);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var request = _jquery2.default.ajax({ url: 'https://jsonplaceholder.typicode.com/posts/1' }); // write ES2015 code and import modules from npm
// and then press "Execute" to run your program
var xs$ = _xstream2.default.fromPromise(request).addListener({ next: function next(resp) {
return console.log('xs', resp);
} });
var rx$ = _rxLite2.default.Observable.fromPromise(request).subscribe(function (resp) {
return console.log('rx', resp);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment