Closed tgriesser closed 9 years ago
Actually, I think I just realized why you'd want to have init
return an empty value, regardless it might be good to get the official word here and update the docs on what an expected value should be when it's not otherwise calling another xf[@@transducer/init']()
I guess also on that note, could the docs be amended to reflect that not all three are "required" to be considered a transformer - only step
, if that is what was decided in #20.
@tgriesser it is not the purpose of init to return any specific thing. It takes no arguments. It should only be invoked in the case that transduce
is invoked with 3 instead of 4 arguments.
Great, thanks for the clarification.
Over on transduce, @kevinbeaty and I have been trying to determine the responsibility of
@@transducer/init
: discussionThe purpose of
init
as a place for defining the initial value of a reduction is clear, but the question is whether it should account for any state or context the object might already retain. In short, doesinit
return:It seems like the cleanest/most useful of those would be number 3, and applied to the example of Immutable.js List, it'd just be a matter of making the current value mutable/immutable:
Thoughts?