made with esnextbin
Created
April 21, 2016 08:54
-
-
Save arlair/29991688d608ddbadbc07706b5c77f86 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> | |
<!-- put markup and other contents here --> | |
<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 {Observable as $} from 'rx' | |
import Cycle from '@cycle/core' | |
import {makeDOMDriver, div, button, p} from 'cycle-snabbdom' | |
import isolate from '@cycle/isolate'; | |
function HiNoClass(sources: any) { | |
const { DOM } = sources; | |
return { | |
DOM: $.just( | |
div([ | |
p('Hi, I have no class :( But I do have scope!') | |
]) | |
) | |
}; | |
} | |
function HiWithClass(sources: any) { | |
const { DOM } = sources; | |
return { | |
DOM: $.just( | |
div({ props: {className: 'IAmHighClass'} }, [ | |
p('Hi, I am classy. I do not need any scope.') | |
]) | |
) | |
}; | |
} | |
function MainView$(sources: any) { | |
return $.just( | |
div([ | |
isolate(HiWithClass)(sources).DOM, | |
isolate(HiNoClass)(sources).DOM, | |
]) | |
); | |
} | |
function main(sources: any) { | |
return { | |
DOM: MainView$(sources) | |
}; | |
} | |
Cycle.run(main, {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": { | |
"rx": "4.1.0", | |
"@cycle/core": "6.0.3", | |
"cycle-snabbdom": "1.2.1", | |
"@cycle/isolate": "1.2.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 _rx = require('rx'); | |
var _core = require('@cycle/core'); | |
var _core2 = _interopRequireDefault(_core); | |
var _cycleSnabbdom = require('cycle-snabbdom'); | |
var _isolate = require('@cycle/isolate'); | |
var _isolate2 = _interopRequireDefault(_isolate); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
function HiNoClass(sources) { | |
var DOM = sources.DOM; | |
return { | |
DOM: _rx.Observable.just((0, _cycleSnabbdom.div)([(0, _cycleSnabbdom.p)('Hi, I have no class :( But I do have scope!')])) | |
}; | |
} | |
function HiWithClass(sources) { | |
var DOM = sources.DOM; | |
return { | |
DOM: _rx.Observable.just((0, _cycleSnabbdom.div)({ props: { className: 'IAmHighClass' } }, [(0, _cycleSnabbdom.p)('Hi, I am classy. I do not need any scope.')])) | |
}; | |
} | |
function MainView$(sources) { | |
return _rx.Observable.just((0, _cycleSnabbdom.div)([(0, _isolate2.default)(HiWithClass)(sources).DOM, (0, _isolate2.default)(HiNoClass)(sources).DOM])); | |
} | |
function main(sources) { | |
return { | |
DOM: MainView$(sources) | |
}; | |
} | |
_core2.default.run(main, { DOM: (0, _cycleSnabbdom.makeDOMDriver)("#app") }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment