Last active
November 7, 2015 18:11
-
-
Save frankandrobot/9015b87140e2e6cf55c3 to your computer and use it in GitHub Desktop.
BaconJS combineTemplate vs HighlandJS zip vs Bluebird join vs BaconJS zip vs Kefir zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const restify = require('restify'); | |
const server = restify.createServer(); | |
const Bacon = require('baconjs'); | |
server.get('/', function(req, res, next) { | |
const a = Bacon.once('a'); | |
const b = Bacon.once('b'); | |
a.flatMap(a => Bacon.combineTemplate({a, b})) | |
.onValue(template => { | |
res.send(template); | |
next(); | |
return Bacon.noMore; //unsubscribe onValue | |
}); | |
}); | |
server.listen(3000, function() { | |
console.log('Listening on port 3000'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const restify = require('restify'); | |
const server = restify.createServer(); | |
const Bacon = require('baconjs'); | |
server.get('/', function(req, res, next) { | |
const a = Bacon.once('a'); | |
const b = Bacon.once('b'); | |
a.zip(b, (a,b) => { return [a, b]; }) | |
.onValue(template => { | |
res.send(template); | |
next(); | |
return Bacon.noMore; //unsubscribe onValue | |
}); | |
}); | |
server.listen(3000, function() { | |
console.log('Listening on port 3000'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const restify = require('restify'); | |
const server = restify.createServer(); | |
const Promise = require('bluebird'); | |
server.get('/', function(req, res, next) { | |
const a = new Promise((res,err) => res('a')); | |
const b = new Promise((res,err) => res('b')); | |
a.then(a => Promise.join(a, b)) | |
.then(template => { | |
res.send(template); | |
next(); | |
}); | |
}); | |
server.listen(3000, function() { | |
console.log('Listening on port 3000'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const restify = require('restify'); | |
const server = restify.createServer(); | |
const h = require('highland'); | |
server.get('/', function(req, res, next) { | |
const a = h(['a']); | |
const b = h(['b']); | |
a.zip(b) | |
.pull((err, template) => { | |
res.send(template); | |
next(); | |
}); | |
}); | |
server.listen(3000, function() { | |
console.log('Listening on port 3000'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Kefir = require('kefir'); | |
const restify = require('restify'); | |
const server = restify.createServer(); | |
server.get('/', function(req, res, next) { | |
const a = Kefir.fromCallback(callback => callback('a')); | |
const b = Kefir.fromCallback(callback => callback('b')); | |
a.zip(b).onValue(template => { | |
res.send(template); | |
next(); | |
}); | |
}); | |
server.listen(3000, function() { | |
console.log('Listening on port 3000'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment