snivilised / lorax

🌟 reactive extensions for go (a pseudo rxgo version 3)
MIT License
5 stars 0 forks source link

rx: allow client control of reduce accumulator #231

Closed plastikfan closed 5 months ago

plastikfan commented 6 months ago

The accumulator needs to be more flexible so that it can work correctly with the Range operator and Sum. The problem at the moment is to do with how the accumultaor is initialised. When the range operator is in play, the items in the observable are generated by an in based for loop. This means that we have to use a Num instance of Item[T]. But, that means the accumulator must also initialised with a Num. But doing this breaks the Sum operator which works on native instances of Item and means Item[T].V is in place because the opaque field is un-set (remains as nil; can't be initialised to 0). The client should have more control over the accumulator.

As I write this, it occurs to me that the Range operator could be improved to not just work with Num instances of Item[T]; this should be addressed in another issue (#232), which should be implemented first before this one.