Skip to content

Instantly share code, notes, and snippets.

@marinho
Created November 2, 2016 22:32
Show Gist options
  • Save marinho/a3901e5a8a4450524736daf06795d60e to your computer and use it in GitHub Desktop.
Save marinho/a3901e5a8a4450524736daf06795d60e to your computer and use it in GitHub Desktop.
trying CycleJS + XStream for the first time
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