If I look at the combine examples in the readme, I felt its API to be a bit unfriendly in the sense that it requires the user to still manually 'apply' the streams to obtain their values, meaning one would not be able to just pass in an existing function. e.g. for flyd.combine((x, y) => x() + y(), [x, y]), I would prefer being able to write say flyd.combine(R.add, [x, y]).
var R = require("ramda");
var flyd = require("flyd");
var combine2 = (f, streams) => flyd.combine(
R.pipe(
function() { return arguments; },
R.dropLast(1),
R.map((stream) => stream()),
R.apply(f)
),
streams
);
var x = flyd.stream(4);
var y = flyd.stream(6);
var sum = combine2(R.add, [x, y]);
x(12);
console.log(sum()); // 18
y(8);
console.log(sum()); // 20
I've no idea if adding an API like this (under whatever name) is considered desirable here, but this was a point that irked me as an outsider. It's admittedly optimized for developer experience rather than for say performance.
If I look at the
combine
examples in the readme, I felt its API to be a bit unfriendly in the sense that it requires the user to still manually 'apply' the streams to obtain their values, meaning one would not be able to just pass in an existing function. e.g. forflyd.combine((x, y) => x() + y(), [x, y])
, I would prefer being able to write sayflyd.combine(R.add, [x, y])
.I tried a PoC to achieve this at RunKit:
I've no idea if adding an API like this (under whatever name) is considered desirable here, but this was a point that irked me as an outsider. It's admittedly optimized for developer experience rather than for say performance.