https://www.learnrxjs.io/operators/combination/pairwise.html
I think that would solve https://stackoverflow.com/questions/53675041/flutter-streams-how-to-access-previously-emitted-data-from-the-stream
I found it handy in some Angular TS situations.
At first glance, it looks a lot like bufferCount(2, 1).
I'll have a closer look later :)
@zoechi How would this solve my question on StackOverflow. https://stackoverflow.com/questions/53675041/flutter-streams-how-to-access-previously-emitted-data-from-the-stream
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