Skip to content

Instantly share code, notes, and snippets.

@TylorS
Last active March 8, 2016 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TylorS/cc30f6b0513a4c2f74ee to your computer and use it in GitHub Desktop.
Save TylorS/cc30f6b0513a4c2f74ee 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>
<!-- put markup and other contents here -->
<div id='app'></div>
</body>
</html>
const Cycle = require('@cycle/core')
const {h, div, makeDOMDriver} = require('cycle-snabbdom')
const Rx = require('rx')
const main = function(sources){
return {
DOM: Rx.Observable.just(1).map(() =>
div('#app', {}, ['XXX'])
)
}
}
const container = document.getElementById('app')
setTimeout(() => {
console.log(container)
const patchedNode = document.getElementById('app')
console.log(container === patchedNode)
}, 1000)
Cycle.run(main, {
DOM: makeDOMDriver(container)
})
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"@cycle/core": "6.0.3",
"cycle-snabbdom": "1.1.1",
"rx": "4.1.0"
}
}
'use strict';
var Cycle = require('@cycle/core');
var _require = require('cycle-snabbdom');
var h = _require.h;
var div = _require.div;
var makeDOMDriver = _require.makeDOMDriver;
var Rx = require('rx');
var main = function main(sources) {
return {
DOM: Rx.Observable.just(1).map(function () {
return div('#app', {}, ['XXX']);
})
};
};
var container = document.getElementById('app');
setTimeout(function () {
console.log(container);
var patchedNode = document.getElementById('app');
console.log(container === patchedNode);
}, 1000);
Cycle.run(main, {
DOM: makeDOMDriver(container)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment