Stream Recap | RxJs Scan, Trapezoid Rule

Another Tuesday another successful stream! I did a little prep work that I mention below for this one and it was nice having notes to follow to keep things organized. However the more I am working through my analysis the more I am questioning my approach. I think next week I am going to build a live chart of the values to get a sense of where I am and where I should god. Then after that ... Linear Regressions!

I got a little excited about the idea and ended up doing an impromptu stream ... that didn't go very well but was extremely instructive:

I spent quite a bit of time trying to create a 'last 10 values' stream. I went through several approaches and ended up with using scan. Originally I tried bufferCount however buffer only emited 'last 10' values for every 10 values. This wouldn't work as I wanted to emit a new 'last 10' for each new value. Then I attempted to use window which almost seemed to work. I was looking to create an Observable<Observable<Array<Number>>> and window provided a Observable<Observable<T>> output, but shamefully I couldn't get the behavior I was looking for.

Having thoroughly overthought the problem, a google search suggested scan and I thought 'sure why not'. It ended up doing the trick quite nicely.

Pay attention to what are Operators and what are Observables. Especially when using mergeMap/concatMap/switchMap. I regularly was getting my types wrong on my inputs and outputs.