Skip to content

Instantly share code, notes, and snippets.

@EnigmaCurry
Last active March 14, 2017 18:23
Show Gist options
  • Save EnigmaCurry/3770c6fca6c22d2f001ae257d563e2bd to your computer and use it in GitHub Desktop.
Save EnigmaCurry/3770c6fca6c22d2f001ae257d563e2bd 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>
<div id='app'></div>
</body>
</html>
import {table, th, tr, td, makeDOMDriver} from '@cycle/dom'
import run from '@cycle/run'
import xs from 'xstream'
const data$ = xs.of([
{name:'ryan', height:'198'},
{name:'mary', height:'152'},
{name:'robert', height:'272'}
])
function main(sources) {
const table$ = data$.map(entries => {
return table({attrs: {border:''}}, [
tr([th('name'), th('height')]),
...entries.map(entry => {
return tr([td(entry.name), td(entry.height)])
})
])
})
return {
DOM: table$
}
}
run(main, {
DOM: makeDOMDriver('#app')
})
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"@cycle/dom": "16.0.0",
"@cycle/run": "1.0.0-rc.9",
"xstream": "10.2.0",
"babel-runtime": "6.22.0"
}
}
'use strict';
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _dom = require('@cycle/dom');
var _run = require('@cycle/run');
var _run2 = _interopRequireDefault(_run);
var _xstream = require('xstream');
var _xstream2 = _interopRequireDefault(_xstream);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var data$ = _xstream2.default.of([{ name: 'ryan', height: '198' }, { name: 'mary', height: '152' }, { name: 'robert', height: '272' }]);
function main(sources) {
var table$ = data$.map(function (entries) {
return (0, _dom.table)({ attrs: { border: '' } }, [(0, _dom.tr)([(0, _dom.th)('name'), (0, _dom.th)('height')])].concat((0, _toConsumableArray3.default)(entries.map(function (entry) {
return (0, _dom.tr)([(0, _dom.td)(entry.name), (0, _dom.td)(entry.height)]);
}))));
});
return {
DOM: table$
};
}
(0, _run2.default)(main, {
DOM: (0, _dom.makeDOMDriver)('#app')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment