Closed Raynos closed 10 years ago
I don't like that since print
in the chain may cause behavior change depending on the input since actual input
will be consumed twice. I don't mind making things chainable, but it shoud be clean (and should be diff function). I pointed out something introspect few times I. I don't think that should be API but that gives you an idea. I want introspect to take:
introspect(input, {
onValue: ..,
onEnd: ...,
onError: ...
}) => input
@Gozala your right I think I want introspect.
However making print return a source isn't going to hurt anyone. I'm well aware it will reduce it twice which is fine in the cases that it's fine. Make your source side-effect free.
@raynos no it's far from obvious that if my input is fs.read under the hood that it will read file twice. It can get confusing very quickly. I prefer not have APIs in the core that would trip up users. There is already big enough change from common patterns to scare a lot of users. It's important to keep balance.
But again that's not an issues for your use case just put your own function into chain instead of reducers print
and problem solved.
P.S.: I'm even considering to move debug out of reducers into separate package.
if you move debug out then also add introspect. It's introspect I want, not debug.
@Gozala note my only use-case for print is for debugging my unit tests. It's very convenient for my chaining flow for it to just return the source.
Closing this due to staleness