Last active
August 27, 2016 17:06
-
-
Save lmatteis/10a7790dcdd1d1f37c18ed95dfb55ccb to your computer and use it in GitHub Desktop.
Treating "cycle apps" as drivers
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
// github-cycle.js | |
function main (sources) { | |
let request$ = sources.props$ | |
.map((prop) => { | |
url: 'http://github.com/api/' + prop, | |
}) | |
let response$ = sources.HTTP | |
.flatten(); | |
let text$ = response$ | |
.map(res => res.text) | |
.startWith('Loading...') | |
return { | |
text$, | |
HTTP: request$ | |
}; | |
} | |
exports = Cycle.run(main, { HTTP: makeHTTPDriver(), props: ??? }) | |
// DIFFERENT FILE | |
// main.js | |
var github = require('github-cycle') // the above file | |
// i'd like to use this above "cycle app", | |
// without knowing about HTTP. | |
function main (sources) { | |
let input$ = xs.of('github/repo/cyclejs') | |
let output$ = sources.GITHUB | |
.map((data) => console.log(data)) | |
return { | |
GITHUB: input$ | |
} | |
} | |
Cycle.run(main, { GITHUB: github }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment