made with esnextbin
test behaviors...
sampleCombine behavior xs.combine behavior map + flatten behavior
made with esnextbin
test behaviors...
sampleCombine behavior xs.combine behavior map + flatten behavior
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
</head> | |
<body> | |
<div id="container"></div> | |
</body> | |
</html> |
import xs from 'xstream' | |
import sampleCombine from 'xstream/extra/sampleCombine' | |
const a$ = xs.periodic( 400 ).map( i => `${i}-a`).take(10) | |
const b$ = xs.periodic( 1100 ).map( i => `${i}-b`).take(6) | |
const result$ = a$.compose( sampleCombine( b$ )) | |
// const result$ = b$.compose( sampleCombine( a$ )) | |
// const result$ = xs.combine( a$, b$ ) | |
// const result$ = a$.map( a => b$.map( b=> [a, b] )).flatten() | |
result$.addListener({ | |
next: console.log, | |
complete: () => console.log('completed') | |
}) |
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"xstream": "9.3.0" | |
} | |
} |
'use strict'; | |
var _xstream = require('xstream'); | |
var _xstream2 = _interopRequireDefault(_xstream); | |
var _sampleCombine = require('xstream/extra/sampleCombine'); | |
var _sampleCombine2 = _interopRequireDefault(_sampleCombine); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var a$ = _xstream2.default.periodic(400).map(function (i) { | |
return i + '-a'; | |
}).take(10); | |
var b$ = _xstream2.default.periodic(1100).map(function (i) { | |
return i + '-b'; | |
}).take(6); | |
var result$ = a$.compose((0, _sampleCombine2.default)(b$)); | |
// const result$ = b$.compose( sampleCombine( a$ )) | |
// const result$ = xs.combine( a$, b$ ) | |
// const result$ = a$.map( a => b$.map( b=> [a, b] )).flatten() | |
result$.addListener({ | |
next: console.log, | |
complete: function complete() { | |
return console.log('completed'); | |
} | |
}); |