Here's a new Rx operator I made for a specific use case, but I've seen myself using it for more use cases so I guess it was a good candidate for this repository.
Basically, flatScan is a scan operator that returns an Observable<T> instead of just T and flatten the result. It's declined in flatScanFirst and flatScanLatest versions that works the same as their flatMap counterparts.
The most useful use case is when working with paginated content when you want to make a new API request with an "offset" and append your new results to current local results. Something like that:
I know I should have discussed this operator in an issue first but the code was already existing in my project but without unit tests (π±) and working on a PR directly encouraged me to write unit tests for it. If you feel like this operator doesn't fit in this repository I wouldn't mind closing this PR. At least I'll be able to add the tests to my project π
PS: In the second commit I fixed swift lint issues unrelated to the flatScan operator. Feel free to focus your review on the first commit 7332d10 π
Hi community!
Here's a new Rx operator I made for a specific use case, but I've seen myself using it for more use cases so I guess it was a good candidate for this repository.
Basically,
flatScan
is ascan
operator that returns anObservable<T>
instead of justT
and flatten the result. It's declined inflatScanFirst
andflatScanLatest
versions that works the same as theirflatMap
counterparts.The most useful use case is when working with paginated content when you want to make a new API request with an "offset" and append your new results to current local results. Something like that:
I know I should have discussed this operator in an issue first but the code was already existing in my project but without unit tests (π±) and working on a PR directly encouraged me to write unit tests for it. If you feel like this operator doesn't fit in this repository I wouldn't mind closing this PR. At least I'll be able to add the tests to my project π
PS: In the second commit I fixed swift lint issues unrelated to the
flatScan
operator. Feel free to focus your review on the first commit 7332d10 π