staltz / rxmarbles

Interactive diagrams of Rx Observables
http://www.rxmarbles.com
BSD 3-Clause "New" or "Revised" License
4.21k stars 537 forks source link

Added aggregate example #4

Closed cristinecula closed 10 years ago

cristinecula commented 10 years ago

First of all let me say that I love rxmarbles! It has helped me alot in understanding how rxjs observables work.

I think that aggregate is not simply a clone of scan, since it emits only the final value of the aggregation. I found this extremely useful after doing a groupBy to create another stream where the groups are reduced to single values with accumulated properties:

    .groupBy (log) -> 
        log.day
    .flatMap (group) -> 
        group.aggregate (acc, log) -> 
            acc.downtime += log.downtime
            acc

Therefore I think this transformation deserves it's own place in the examples.

cristinecula commented 10 years ago

On second thought, I have noticed that the reduce method already exists and it's basically the same thing. I'm not sure if they should both be present, it might create confusion :)

staltz commented 10 years ago

Hi @cristinecula I appreciate your issue and PR! And true, I don't know what's the difference between reduce and aggregate, and reduce is in rxmarbles already. https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/aggregate.js https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/reduce.js

Currently I'm focusing on building features that are necessary for showing more operators. For instance, some operators depend a lot when the onCompleted happens, so I'm working on rendering the onCompleted marker. Also other operators are error-related so first need to render errors. Then there are metastream operators, etc.

cristinecula commented 10 years ago

Thank you @staltz for the reply. I will close this pull request for now and will continue following your awesome project.

staltz commented 10 years ago

:+1: PRs and issues appreciated. My focus is to get more operators included, but as far as I see, not all of them will be in rxmarbles, because they don't make sense as a diagram. For example, doWhile.