Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R.groupBy and flyd.transduce #126

Open
ghost opened this issue Oct 24, 2016 · 1 comment
Open

R.groupBy and flyd.transduce #126

ghost opened this issue Oct 24, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 24, 2016

Hi,

I like flyd and its interoperability with R transducers.

However, I have some troubles with R.groupBy that I don't have with the other transducers ( ie R.map )

`var stream = flyd.stream()
var transduce = flyd.transduce ( R.groupBy( x => String( x%2 ) ), stream )

flyd.map( console.log , transduce )

stream(1)
stream(2)

console.log( transduce() )
`

Output is undefined and not the result of groupBy

I try partitionBy from transducers-js and it seems to work well.

Thanks in advance for your reply

@nordfjord
Copy link
Collaborator

I did some investigation into this:

the transducer version of R.groupBy is implemented here: https://github.com/ramda/ramda/blob/master/source/internal/_xreduceBy.js

the @@transducer/step method is of particular interest, as you can see the last line is: return result. However result is not modified at all in the transducer.

Flyd's transduce implementation requires the step method to return a value which ramda's groupBy unfortunately does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant