Open Gozala opened 11 years ago
Only solution I can imagine of is by required end
value even in cases when reduced(value)
is returned by a consumer. Unfortunately this adds complexity on the side of input
source implementer. In addition broken input
may break expectations by sending more values after reduced(value)
is returned.
This also means that errors may occur in attempt to finalize
input which would mean errors after reduced(value)
may occur, which complicates API.
@Raynos feedback and suggestions on this subject is very welcome.
This is a pain in the ass. All I want to know is whether a reducible is finished not being able to put more values into a reducible.
Finalize means we can add more values into a finished reducible which is silly. You need some kind of onBeforeFinish hook which can't be done when user sends reduced(...)
You can still do finalize just don't reduce the result of it.
At the moment once reducer returns
reduced(result)
consumedinput
is signaled that reducer no longer wishes to consume it. In a way it's a signal to stop an input. Any further values yield will are suppressed by reducible which is core function for creating reducibles.Unfortunately this design choice prevents performing any asynchronous finalization tasks after
reduced(value)
is returned. Consider a case where reducible task represents:If only parts of the content is read
fs.close
is never executed. Obviously this can be fixed by adding some function likefinalize
:The problem is though that according to an API stream should not yield anything after
reduced(value)
is returned by a consumer. Although if async task is just executed in case of error there will be no one handling it.