Skip to content

Instantly share code, notes, and snippets.

@artisonian
Created June 5, 2015 00:23
Show Gist options
  • Save artisonian/9677a6fc5301a589299d to your computer and use it in GitHub Desktop.
Save artisonian/9677a6fc5301a589299d to your computer and use it in GitHub Desktop.
{
"jsxPragma": "element"
}
node_modules
build/*
import {element} from 'deku'
let propTypes = {
items: {
source: 'channelItems'
}
}
function render (component) {
let {props} = component
let items = props.items.map(x => <li>{x}</li>)
return (
<ul>{items}</ul>
)
}
export default {propTypes, render}
import 'babelify/polyfill'
import {chan, go, put, take, timeout} from 'js-csp'
import {element, tree, render} from 'deku'
import Container from './container'
let ch = chan()
go(function *() {
while (yield put(ch, 1)) yield take(timeout(250))
})
go(function *() {
while (yield put(ch, 2)) yield take(timeout(300))
})
go(function *() {
while (yield put(ch, 3)) yield take(timeout(1000))
})
let app = tree(<Container />)
app.set('channelItems', [])
go(function *() {
let items = []
for (let i = 0; i < 10; i++) {
items.push(yield take(ch))
app.set('channelItems', items)
}
ch.close()
})
render(app, document.body)
{
"dependencies": {
"babelify": "^6.1.2",
"browserify": "^10.2.3",
"deku": "^0.4.3",
"js-csp": "^0.4.1"
},
"devDependencies": {
"wzrd": "^1.3.0"
},
"scripts": {
"build": "browserify --transform babelify --outfile build/bundle.js index.js",
"start": "wzrd index.js -- -t babelify -d"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment