Skip to content

Instantly share code, notes, and snippets.

@lmatteis
Last active August 27, 2016 17:06
Show Gist options
  • Save lmatteis/10a7790dcdd1d1f37c18ed95dfb55ccb to your computer and use it in GitHub Desktop.
Save lmatteis/10a7790dcdd1d1f37c18ed95dfb55ccb to your computer and use it in GitHub Desktop.
Treating "cycle apps" as drivers
// 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