- Clear feature ownership
- Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
var svg = document.getElementById('graph'), | |
xml = new XMLSerializer().serializeToString(svg), | |
data = "data:image/svg+xml;base64," + btoa(xml), | |
img = new Image() | |
img.setAttribute('src', data) | |
document.body.appendChild(img) |
// Limit the rate of flow to an event every 250ms: | |
// const stream$ = other$.thru(limitFlow(250)); | |
export function limitFlow(period) { | |
return function limitFlow(stream) { | |
const source = new RateLimitSource(stream.source, period); | |
return new stream.constructor(source); | |
}; | |
} |
import {Observable, Disposable} from 'rx'; | |
import {run} from '@cycle/core' | |
const jsondiffpatch = require('jsondiffpatch').create({ | |
objectHash: function(obj) { | |
return obj.name; | |
} | |
}); | |
function generateCurve(steps){ | |
var curve = new Float32Array(steps) |
var mqtt = require('mqtt') | |
// Make sure to change this to the IP address of your MQTT server | |
, host = '192.168.128.204' // or localhost | |
client = mqtt.createClient(1883, host, {keepalive: 10000}); | |
// Subscribe to the temperature topic | |
client.subscribe('temperature'); | |
// When a temperature is published, it will show up here | |
client.on('message', function (topic, message) { |
#grid { | |
border: 1px solid #000; | |
border-spacing:0; | |
} | |
#grid tr:nth-child(3) td, | |
#grid tr:nth-child(6) td { | |
border-bottom: 1px solid #000; | |
} |
/***************************************************************************** | |
This is the function doing all the heavy lifting. | |
It takes a function and returns a stream generated by feeding its output | |
back into itself as input. (It doesn't start consuming the stream.) | |
It's basically a pared-down version of Cycle.run that forgets about the | |
application architecture of separating out a pure main from the effectful | |
drivers and just resolves a single circularly dependent stream. The other | |
files just build up more API-compatible versions of Cycle.run from this. |
(by @andrestaltz)
So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.
Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:
Rx.Observable.prototype.flatMapLatest(selector, [thisArg])
Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
// ES7 Observables + WHATWG Streams | |
// | |
// https://github.com/jhusain/asyncgenerator | |
// https://github.com/whatwg/streams | |
// | |
// Continuation from file: | |
// https://github.com/jhusain/asyncgenerator/blob/master/src/observable.js | |
Observable.fromStream = function(readable) { | |
return new Observable(function(generator) { |