Rxdart: feature request pairwise

Created on 8 Dec 2018  路  10Comments  路  Source: ReactiveX/rxdart

All 10 comments

At first glance, it looks a lot like bufferCount(2, 1).

I'll have a closer look later :)

With each event you get the new value and the previous value.
If [1, 2, 3, 4, 5] are emitted one by one to the stream, pairwise would emit
[1, null], [2, 1], [3, 2], [4, 3], [5, 4].
Is this not what you want?

Yes it is what i want, i just don't know how to use this. I was dealing with ReplaySubject, which isn't working for me. If you could answer my question on StackOverflow with a sample example, it would be just great!

It does not exist yet. bufferCount (instead of pairwise) should do that when #210 is merged and an update published to pub.

Okay! I understand. But still i should have been able to use Replay Subject. I want to learn how to use Replay Subject. Currently in my Replay Subject if i add 1, it shows [1]; now i add 2, it becomes [2,2]; then i add 3, it becomes [3,3,3].

So as you see it gets overridden. This is strange and defeats the purpose of Replay Subject.
I thought my replay subject is getting initialized every time, but if thats the case how are the no. of elements in the stream keep on incrementing. What i mean is, if my constructor for Replay Subject was getting recalled, it should have given me an output [1] then [2] and then [3] instead of [1], then [2,2] and then [3,3,3].

Thus, i believe the problem is something else. Can you point out an implementation of Replay Subject

A self-contained running example would probably be helpful to diagnose.
The maintainers here know much more about that than me anyway.

For ReplaySubject, it always helps to check out the tests: https://github.com/ReactiveX/rxdart/blob/master/test/subject/replay_subject_test.dart

fixed in 0.20.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

erf picture erf  路  3Comments

jonsamwell picture jonsamwell  路  4Comments

qiangjindong picture qiangjindong  路  3Comments

BugsBunnyBR picture BugsBunnyBR  路  7Comments

cedvdb picture cedvdb  路  4Comments