I have a simple script which just take all values from Redis list and print them to console.
var redis = require("redis"),
client = redis.createClient();
Bacon = require('baconjs');
Bacon.repeat(function(){
return Bacon.fromNodeCallback(
client, 'lpop', ['errors']
);
})
.takeWhile(function(val) {return val !== null;})
.fold(
[],
function(acc, next) {
acc.push(next); return acc;
}
).onValue(console.log);
The program prints the correct list but never finishes. How can I fix the issue? And why does it happen?