flyd-mirror
v0.7.0
Published
Create an on-demand mirror of a flyd datastructure
Downloads
20
Readme
flyd-mirror
A small (0.8 kB min+gzip) module for flyd
that can generate mirrors and images, useful when you want to combine
reactive programming with plain old JavaScript objects.
Install
npm install flyd-mirrorExamples
image is mirroring streams...
var data = {
name: flyd.stream("Fry"),
age: flyd.stream(1023)
};
var image = fm.image(data);
assert.equal(image.name(), "Fry");
assert.equal(image.age(), 1023);...while mirror is listening to these images...
var sq = fm.mirror(function() {
return image.age()*image.age();
});
assert.equal(sq(), 1046529);
data.age(1024); // happy birthday!
assert.equal(sq(), 1048576);making it possible for the mirror to automatically update when the underlying streams are updated.
