How to implement "partial reduce"? #6726
Unanswered
d-bassarab
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
"Partial reduce" is not the best name so let's look at the input:
The goal is to produce sub-arrays starting with 'a?' and having all 'b?' until next 'a?' comes along:
Note that initial 'b?'s where skipped because there was no preceding 'a?'.
Having limited rxjs experience the only solution I could come up with looks like this:
But it doesn't feel right because of sharing, double subscription and double processing of the stream. Is there a magical combination of operators that does the same better?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions