my_Stream是我要累积并分配给变量以进行进一步处理的数据。我的问题:一旦流完成,如何将变量the_string的内容发送到console.log?
my_Stream.onValue(function(value) {
the_string = the_string.concat(value);
});
我的完整代码可以在github问题页面上找到:github.com/nodeschool/discussions/issues/1778
您要使用的是fold
,它扫描流并仅在流结束时才输出值。
const stream = Bacon.sequentially(100, ["Hello", "world"])
stream.log("stream")
const concatenated = stream.fold("", (a,b) => a + b)
concatenated.log("concatenated")
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句