Skip to content

Instantly share code, notes, and snippets.

@trxcllnt
Created April 15, 2016 19:37
Show Gist options
  • Save trxcllnt/774d9171a34dafaf07ce121f17bcbbfe to your computer and use it in GitHub Desktop.
Save trxcllnt/774d9171a34dafaf07ce121f17bcbbfe 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>
import { Observable, ReplaySubject } from 'rxjs/Rx';
Observable
.fromPromise(new Promise((res) => res(true)))
.map(() => 'abc')
.do(() => console.log('LOG_1'))
.multicast(() => new ReplaySubject())
.refCount()
.do(() => console.log('LOG_2'))
.flatMap(() => Observable.timer(500)
.flatMap(() => Observable.throw('ERR')))
.retry(3)
.subscribe(() => {})
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"babel-runtime": "6.6.1",
"rxjs": "5.0.0-beta.6"
}
}
'use strict';
var _promise = require('babel-runtime/core-js/promise');
var _promise2 = _interopRequireDefault(_promise);
var _Rx = require('rxjs/Rx');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_Rx.Observable.fromPromise(new _promise2.default(function (res) {
return res(true);
})).map(function () {
return 'abc';
}).do(function () {
return console.log('LOG_1');
}).multicast(function () {
return new _Rx.ReplaySubject();
}).refCount().do(function () {
return console.log('LOG_2');
}).flatMap(function () {
return _Rx.Observable.timer(500).flatMap(function () {
return _Rx.Observable.throw('ERR');
});
}).retry(3).subscribe(function () {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment