made with esnextbin
Last active
November 8, 2016 15:42
-
-
Save ntilwalli/400df16b8277a7c0a22d43df0d082173 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains hidden or 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-main"></div> | |
</body> | |
</html> |
This file contains hidden or 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
// write ES2015 code and import modules from npm | |
// and then press "Execute" to run your program | |
import Cycle from '@cycle/xstream-run' | |
import {makeDOMDriver, div, input} from '@cycle/dom' | |
import isolate from '@cycle/isolate' | |
import xs from 'xstream' | |
function child(sources) { | |
const {DOM} = sources | |
const input$ = DOM.select(`.appInput`).events(`keyup`) | |
.map(ev => ev.target.value) | |
.debug(x => console.log(x)) | |
const vtree$ = input$ | |
.startWith(``) | |
.map(val => { | |
console.log(`val`, val) | |
return div([ | |
input( | |
`.appInput`, { | |
attrs: { | |
type: "text", | |
value: val | |
} | |
}) | |
]) | |
}) | |
return { | |
DOM: vtree$ | |
} | |
} | |
function main(sources) { | |
const child1 = isolate(child)(sources) | |
const child2 = isolate(child)(sources) | |
return { | |
DOM: xs.combine(child1.DOM, child2.DOM) | |
.map((children) => div(children)) | |
} | |
} | |
Cycle.run(main, { | |
DOM: makeDOMDriver('#app-main') | |
}) |
This file contains hidden or 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": { | |
"@cycle/xstream-run": "3.1.0", | |
"@cycle/dom": "14.0.0", | |
"@cycle/isolate": "1.4.0", | |
"xstream": "7.0.0" | |
} | |
} |
This file contains hidden or 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 _xstreamRun = require('@cycle/xstream-run'); | |
var _xstreamRun2 = _interopRequireDefault(_xstreamRun); | |
var _dom = require('@cycle/dom'); | |
var _isolate = require('@cycle/isolate'); | |
var _isolate2 = _interopRequireDefault(_isolate); | |
var _xstream = require('xstream'); | |
var _xstream2 = _interopRequireDefault(_xstream); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
// write ES2015 code and import modules from npm | |
// and then press "Execute" to run your program | |
function child(sources) { | |
var DOM = sources.DOM; | |
var input$ = DOM.select('.appInput').events('keyup').map(function (ev) { | |
return ev.target.value; | |
}).debug(function (x) { | |
return console.log(x); | |
}); | |
var vtree$ = input$.startWith('').map(function (val) { | |
console.log('val', val); | |
return (0, _dom.div)([(0, _dom.input)('.appInput', { | |
attrs: { | |
type: "text", | |
value: val | |
} | |
})]); | |
}); | |
return { | |
DOM: vtree$ | |
}; | |
} | |
function main(sources) { | |
var child1 = (0, _isolate2.default)(child)(sources); | |
var child2 = (0, _isolate2.default)(child)(sources); | |
return { | |
DOM: _xstream2.default.combine(child1.DOM, child2.DOM).map(function (children) { | |
return (0, _dom.div)(children); | |
}) | |
}; | |
} | |
_xstreamRun2.default.run(main, { | |
DOM: (0, _dom.makeDOMDriver)('#app-main') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment