dotnet / dotnet/reactive

Does a Pairwise operator belong in here?

Open
#1,629 0 comments 1 reaction 0 assignees View on GitHub
[area] Rx
Dominant language
C#
Stars
7.2k
Forks
798
PR merge metrics
No merged PRs in 30d

Description

### Reasoning:
_UniRx_ which started as a _System.Reactive_ fork has a Pairwise operator and so does the rx.js.
I added that operator in a 3rd party library for now but I'm curious if a lot of people would prefer it to be part of _System.Reactive_ as well.
I feel like this is a common and easily understood operator to appear in rx based implementation scenarios.

### Implementation approaches:
It could be achieved by just doing
```cs
source
.Buffer(2, 1)
.Where(b => b.Count > 1)
.Select(b => new Pair(previous: b[0], current: b[1]))
```
I think, though this is not ideal as it's hard to decipher that that's just a pairwise when reading a stack trace and it could compromise performance when used extensively. This is why I haven't done it like that yet. Instead I implemented my own operator for this. (I'd be willing to provide this as well as a test in a PR if consent is reached.)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.