RxSwift icon indicating copy to clipboard operation
RxSwift copied to clipboard

Proposal, add overlapping buffers.

Open danielt1263 opened this issue 1 year ago • 2 comments
trafficstars

I always thought it odd that the overlapping buffers which are offered in the core .NET Rx implementation and documented in the Introduction to Rx book are not part of RxSwift. I've had personal implementations that I wrote back in 2019, and I was thinking it would be nice to finally add them to the library. Maybe I should add them to the RxSwiftExt library instead?

What do you all think?

danielt1263 avatar Apr 29 '24 10:04 danielt1263

Can you share how that use case would look? Maybe example input / output so I can better understand ?

In general the aim of the library is to add mainly useful operators and not just theoretically useful ones so would be great finding the use case for such a new operator

Thanks for the suggestion!

freak4pc avatar Apr 29 '24 11:04 freak4pc

There is an example in the book (that I linked, but you have to scroll down a ways) that uses an overlapping buffer to calculate the average speed of a vessel, and I've used it for that sort of thing in the past.

I have also used it to smooth out jitter while reading the accelerometer input.

Lastly, an overlapping buffer comes in handy when you want the two most recent values emitted from an observable. It's cleaner than doing the whole share/skip/zip dance. Instead, you just do .buffer(count: 2, skip: 1).

danielt1263 avatar Apr 29 '24 11:04 danielt1263