Brings websocket power to your Cycle.js app 🤘
This code launches a cycle app with a ws server listening for requests, and broadcasts back the UPPERCASE payload.
const makeWSDriver = require('cycle-websocket');
const {run} = require('@cycle/xstream-run');
const drivers = {
ws: makeWSDriver({
port: 1337
}
}
// your app
const main = (sources) => {
// sinks
return {
ws: sources.ws.map(input => input.toUpperCase())
}
}
run(main, drivers);
npm install cycle-websocket
Uses ES6 features.
This was built and tested for node, not tested in the browser but it should work. Keep me in touch if it's working or not !
The input and output of the driver have unit tests. Don't mind the tooling, I moved it directly from the project I'm working on. Since it's only tests and readable, I kept it.
[] Support other stream libs than xstream (use an adapter !) [] Test for browser environments :D [] Any suggestions ?
Feel free to send me a pull request on anything (code, tests, doc, RC). I'll be glad to review that.
Build & Learn everyday
Full stack engineer concerned about building awesome stuff to improve people's life.