Created
November 2, 2016 22:32
-
-
Save marinho/a3901e5a8a4450524736daf06795d60e to your computer and use it in GitHub Desktop.
trying CycleJS + XStream for the first time
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 { makeDOMDriver, div } from '@cycle/dom'; | |
// import { Observable } from 'rxjs/Observable'; | |
const | |
html = require('./panel.html'), | |
css = require('./panel.css'); | |
function main() { | |
const subscriptions$ = xs.of([ | |
{ name: 'just testing 1' }, | |
{ name: 'just testing 2' }, | |
{ name: 'just testing 3' }, | |
{ name: 'just testing 4' }, | |
]); | |
const subscriptionsDom$ = subscriptions$ | |
.map(subs => xs.from(subs)) | |
.flatten() | |
.map(sub => { | |
return div('.section-row', [ | |
div('.section-cell.section-cell--fixed-2', [ | |
'XXX' | |
]), | |
div('.section-cell.section-cell--flex.align-center', [ | |
'XXX1' | |
]), | |
div('.section-cell.section-cell--fixed-1.align-right', [ | |
'XXX2' | |
]) | |
]); | |
}) | |
.fold((r, t) => r.concat([t]), []); | |
const sinks = { | |
subscriptionsCount: subscriptions$.map(x => x.length), | |
subscriptionsList: subscriptionsDom$ | |
}; | |
return sinks; | |
} | |
const drivers = { | |
subscriptionsCount: makeDOMDriver('#subscriptionsCount'), | |
subscriptionsList: makeDOMDriver('#subscriptionsList') | |
}; | |
run(main, drivers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment