made with esnextbin
Created
December 4, 2016 15:00
-
-
Save andreloureiro/8cc21972e2b44d17c1a32b97a78d1bc7 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<div id="app"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xs from 'xstream'; | |
import {div, makeDOMDriver} from '@cycle/dom'; | |
import {run} from '@cycle/xstream-run'; | |
import isolate from '@cycle/isolate'; | |
const random = () => Math.floor(Math.random() * 10); | |
const ns$ = xs.periodic(1000).debug('n').map(_ => random()); | |
const r$ = ns$.fold(n => state => state.concat(n), []).remember(); | |
const dom$ = r$.map(c => JSON.stringify(c)); | |
run(() => ({DOM: dom$}), {DOM: makeDOMDriver('#app')}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"xstream": "9.0.0", | |
"@cycle/dom": "14.1.0", | |
"@cycle/xstream-run": "4.0.0", | |
"@cycle/isolate": "1.4.0", | |
"babel-runtime": "6.18.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var _stringify = require('babel-runtime/core-js/json/stringify'); | |
var _stringify2 = _interopRequireDefault(_stringify); | |
var _xstream = require('xstream'); | |
var _xstream2 = _interopRequireDefault(_xstream); | |
var _dom = require('@cycle/dom'); | |
var _xstreamRun = require('@cycle/xstream-run'); | |
var _isolate = require('@cycle/isolate'); | |
var _isolate2 = _interopRequireDefault(_isolate); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var random = function random() { | |
return Math.floor(Math.random() * 10); | |
}; | |
var ns$ = _xstream2.default.periodic(1000).debug('n').map(function (_) { | |
return random(); | |
}); | |
var r$ = ns$.fold(function (n) { | |
return function (state) { | |
return state.concat(n); | |
}; | |
}, []).remember(); | |
var dom$ = r$.map(function (c) { | |
return (0, _stringify2.default)(c); | |
}); | |
(0, _xstreamRun.run)(function () { | |
return { DOM: dom$ }; | |
}, { DOM: (0, _dom.makeDOMDriver)('#app') }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment