Skip to content

Instantly share code, notes, and snippets.

@fuunnx
Last active November 30, 2016 16:47
Show Gist options
  • Save fuunnx/22ba1da1ed16e7a371ae4ff2ccd902e0 to your computer and use it in GitHub Desktop.
Save fuunnx/22ba1da1ed16e7a371ae4ff2ccd902e0 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 -->
<style>svg { background: #eee; }</style>
</head>
<body>
<div id="app"></div>
<!-- put markup and other contents here -->
</body>
</html>
import {run} from '@cycle/xstream-run'
import {h, div, label, input, hr, h1, svg, makeDOMDriver} from '@cycle/dom'
import xs from 'xstream'
function main(sources) {
// Does not work as expected
/*const vtree$ = xs.of(
svg('.mySvg', {}, [])
)
.debug(`svg('.mySvg', {}, []) ->
`)
*/
// Does not work as expected
/*const vtree$ = xs.of(
h('svg.mySvg', {}, [])
)
.debug(`h('svg.mySvg', {}, []) ->
`)
*/
// Works as expected :
const vtree$ = xs.of(
svg({ attrs: { class: 'mySvg' } }, [])
)
.debug(`svg({ attrs: { class: 'mySvg' } }, []) ->
`)
return {
DOM: vtree$,
}
}
run(main, { DOM: makeDOMDriver('#app') })
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"@cycle/xstream-run": "4.0.0",
"@cycle/dom": "14.1.0",
"xstream": "7.0.0"
}
}
'use strict';
var _xstreamRun = require('@cycle/xstream-run');
var _dom = require('@cycle/dom');
var _xstream = require('xstream');
var _xstream2 = _interopRequireDefault(_xstream);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function main(sources) {
// Does not work as expected
/*const vtree$ = xs.of(
svg('.mySvg', {}, [])
)
.debug(`svg('.mySvg', {}, []) ->
`)
*/
// Does not work as expected
/*const vtree$ = xs.of(
h('svg.mySvg', {}, [])
)
.debug(`h('svg.mySvg', {}, []) ->
`)
*/
// Works as expected :
var vtree$ = _xstream2.default.of((0, _dom.svg)({ attrs: { class: 'mySvg' } }, [])).debug('svg({ attrs: { class: \'mySvg\' } }, []) ->\n');
return {
DOM: vtree$
};
}
(0, _xstreamRun.run)(main, { DOM: (0, _dom.makeDOMDriver)('#app') });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment