Skip to content

Instantly share code, notes, and snippets.

@naoya
Created April 3, 2015 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naoya/37a762d8eeb95622c7e1 to your computer and use it in GitHub Desktop.
Save naoya/37a762d8eeb95622c7e1 to your computer and use it in GitHub Desktop.
var Rx = require('rx');
var stream1 = Rx.Observable.from(['a', 'b', 'c']);
var stream2 = Rx.Observable.from([1, 2, 3]);
var combined = stream1.combineLatest(stream2, function (x, y) {
return x + y;
});
combined.subscribe(function (v) {
console.log(v);
});
/*
$ node app-rxjs.js
a1
b1
b2
c2
c3
*/
var Bacon = require('baconjs');
var stream1 = Bacon.fromArray(['a', 'b', 'c']);
var stream2 = Bacon.fromArray([1, 2, 3]);
var combined = Bacon.combineWith(function(x, y) {
return x + y;
}, stream1, stream2).changes();
combined.onValue(function (v) {
console.log(v);
});
/* output
$ node app.js
c1
c2
c3
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment