flyd-mirror

0.7.0 • Public • Published

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-mirror

Examples

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.

Readme

Keywords

none

Package Sidebar

Install

npm i flyd-mirror

Weekly Downloads

1

Version

0.7.0

License

ISC

Last publish

Collaborators

  • finnsson