made with esnextbin
Last active
December 31, 2016 14:56
-
-
Save Hypnosphi/0765658af0d20a82ff8486df4cdab607 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> | |
<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 xs from 'xstream'; | |
import {run} from '@cycle/xstream-run'; | |
import {makeHTTPDriver} from '@cycle/http'; | |
import {makeDOMDriver, div} from '@cycle/dom'; | |
function main(source) { | |
const response$ = source.HTTP.select() | |
.flatten() | |
const accumulatedResponse$ = response$.fold((acc, res) => acc.concat(res), []); | |
const request$ = xs.periodic(2000) | |
.mapTo({ url: 'https://api.github.com', method: 'GET' }); | |
return { | |
DOM: accumulatedResponse$.map(responses => | |
div(responses.map(res => | |
div([res.body.emails_url]) | |
)) | |
), | |
HTTP: request$ | |
}; | |
} | |
run(main, { | |
DOM: makeDOMDriver('#app'), | |
HTTP: makeHTTPDriver() | |
}); |
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": { | |
"xstream": "9.0.0", | |
"@cycle/xstream-run": "4.2.0", | |
"@cycle/http": "11.2.0", | |
"@cycle/dom": "14.3.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 _xstream = require('xstream'); | |
var _xstream2 = _interopRequireDefault(_xstream); | |
var _xstreamRun = require('@cycle/xstream-run'); | |
var _http = require('@cycle/http'); | |
var _dom = require('@cycle/dom'); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
function main(source) { | |
var response$ = source.HTTP.select().flatten(); | |
var accumulatedResponse$ = response$.fold(function (acc, res) { | |
return acc.concat(res); | |
}, []); | |
var request$ = _xstream2.default.periodic(2000).mapTo({ url: 'https://api.github.com', method: 'GET' }); | |
return { | |
DOM: accumulatedResponse$.map(function (responses) { | |
return (0, _dom.div)(responses.map(function (res) { | |
return (0, _dom.div)([res.body.emails_url]); | |
})); | |
}), | |
HTTP: request$ | |
}; | |
} | |
(0, _xstreamRun.run)(main, { | |
DOM: (0, _dom.makeDOMDriver)('#app'), | |
HTTP: (0, _http.makeHTTPDriver)() | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment