You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.
The 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, does init return:
a new empty value:
returnnewthis.constructor()
the value:
returnthis
a new value retaining some notion of state:
returnnewthis.constructor(into({},this.data))
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:
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.
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?
The text was updated successfully, but these errors were encountered: